如何计算 .ts 文件中的总行数

How to count total no of lines from .ts files

我有 app 文件夹,里面有那么多模块和组件。我只需要计算 .ts 文件的代码行数。那么有没有VS Code的插件或任何其他方式请建议?

您可以使用命令行工具 CLOC(计算代码行数)。

安装:

npm install -g cloc  

用法:

cloc my/app/folder --include-lang=TypeScript

您将得到如下所示的输出:

      88 text files.
      88 unique files.
      32 files ignored.

github.com/AlDanial/cloc v 1.82  T=0.12 s (516.3 files/s, 19421.4 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
TypeScript                      60            276            101           1880
-------------------------------------------------------------------------------
SUM:                            60            276            101           1880
-------------------------------------------------------------------------------

More info

在 Unix 上,您可以使用 wc 来计算文档的行数。

wc -l **/*.ts

您可以尝试安装这个包:sloc

安装:

npm i -g sloc

否则,如果您正在使用vscode,您可以安装行计数器插件