javascript 如何统计一个项目中JS、CSS、LESS、HTML文件的总代码行数?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33774360/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 16:53:25  来源:igfitidea点击:

How to count the total number of line of code for JS, CSS, LESS, HTML files in a project?

javascriptcssgulp

提问by GibboK

I am looking for a way to count the total number of line of code for my front-end project.

我正在寻找一种方法来计算我的前端项目的代码行总数。

At the moment I am using the gulp-sloc

目前我正在使用gulp-sloc

gulp.task('sloc', function () {
    gulp.src(folders)
      .pipe(sloc());
});

But the CSS code is not included in the count.

但是 CSS 代码不包括在计数中。

  • Do I miss some special configuration?
  • Do you know any other similar plugin?
  • 我想念一些特殊的配置吗?
  • 你知道其他类似的插件吗?

回答by hashchange

Perhaps you are using source control? In case that source control is Git, you can count the amount of code in the repo like this– no extra tools required.

也许您正在使用源代码管理?如果源代码控制是 Git,您可以像这样计算 repo 中的代码量——不需要额外的工具。

For a more detailed breakdown, clocmay be helpful – have a look at this answerthen. cloc doesn't depend on Git, or any other type of source control.

有关更详细的细分,cloc可能会有所帮助 -然后查看此答案。cloc 不依赖于 Git 或任何其他类型的源代码控制。

回答by ShaswatWayne

In windows OS there is also a gui tool http://www.locmetrics.com/which you can use to count lines of code (LOC), blank lines of code (BLOC), comment lines of code (CLOC).

在 Windows 操作系统中还有一个 gui 工具http://www.locmetrics.com/,您可以使用它来计算代码行数 (LOC)、代码空白行数 (BLOC)、代码注释行数 (CLOC)。