如何获取 tsc 将编译的 Typescript 文件列表?
How can I get the list of Typescript files that tsc will compile?
我正在尝试在 Typescript 项目中编写一个 grunt
任务来测量源文件的一些统计信息。为此,我有一个函数接受单个源文件,从中运行 typescript.createSourceFile
,并对返回的 AST 执行一些操作。问题是找到所有要迭代的文件:我想获得 tsc -p tsconfig.json
稍后将编译的完全相同的文件列表。目的是从该列表中过滤掉一些文件,然后遍历过滤后的列表。
我想我会使用 typescript
模块来执行此操作,但我找不到执行此操作的函数。我发现 the place in the tsc
source that turns tsconfig into a list of files,它似乎正在使用未导出的函数。
tsc --listFiles --noEmit
这将列出 tsc 将根据它使用的 tsconfig.json
编译的文件。
我想你想要 --listFilesOnly
标志。
Print names of files that are part of the compilation and then stop processing.
示例:
tsc --listFilesOnly path/to/tsconfig.json
我正在尝试在 Typescript 项目中编写一个 grunt
任务来测量源文件的一些统计信息。为此,我有一个函数接受单个源文件,从中运行 typescript.createSourceFile
,并对返回的 AST 执行一些操作。问题是找到所有要迭代的文件:我想获得 tsc -p tsconfig.json
稍后将编译的完全相同的文件列表。目的是从该列表中过滤掉一些文件,然后遍历过滤后的列表。
我想我会使用 typescript
模块来执行此操作,但我找不到执行此操作的函数。我发现 the place in the tsc
source that turns tsconfig into a list of files,它似乎正在使用未导出的函数。
tsc --listFiles --noEmit
这将列出 tsc 将根据它使用的 tsconfig.json
编译的文件。
我想你想要 --listFilesOnly
标志。
Print names of files that are part of the compilation and then stop processing.
示例:
tsc --listFilesOnly path/to/tsconfig.json