From b1caf67f4cd77495731952993d73ff2c30a8e11c Mon Sep 17 00:00:00 2001 From: Christian Liebel Date: Mon, 7 Oct 2024 11:19:19 -0400 Subject: [PATCH] Lab #7 --- tools/my-plugin/src/generators/utils/get-source-file.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tools/my-plugin/src/generators/utils/get-source-file.ts diff --git a/tools/my-plugin/src/generators/utils/get-source-file.ts b/tools/my-plugin/src/generators/utils/get-source-file.ts new file mode 100644 index 0000000..a6b3bc0 --- /dev/null +++ b/tools/my-plugin/src/generators/utils/get-source-file.ts @@ -0,0 +1,7 @@ +import { Tree } from '@nx/devkit'; +import { createSourceFile, ScriptTarget } from 'typescript'; + +export function getSourceFile(tree: Tree, filePath: string) { + const moduleSrc = tree.read(filePath, 'utf-8'); + return createSourceFile(filePath, moduleSrc, ScriptTarget.Latest, true); +}