项目作者: dotvirus

项目描述 :
CLI tool to count lines and other file statistics
高级语言: TypeScript
项目地址: git://github.com/dotvirus/saros.git
创建时间: 2020-06-07T14:36:35Z
项目社区:https://github.com/dotvirus/saros

开源协议:MIT License

下载


saros

CLI tool to count lines and other file statistics.

Node.js CI
npm version
codecov

Install

  1. npm i -g saros

Run CLI

  1. saros --help

CLI example to get file statistics within the current directory (and subfolders), but ignoring node_modules

  1. saros . -R -D -I node_modules

Progammatic usage count

countFiles()

Count all *.js files recursively, ignoring node_modules and return a sum per extension

  1. const saros = require("saros");
  2. saros
  3. .countFiles({
  4. recursive: true,
  5. path: ".",
  6. ignore: ["node_modules"],
  7. extensions: [".js"],
  8. })
  9. .then((data) => {
  10. console.log(data);
  11. })
  12. .catch((err) => {
  13. console.log(err);
  14. });
  15. // Example output:
  16. // {
  17. // timeMs: 5,
  18. // numFiles: 1,
  19. // numFilesPerExtension: {
  20. // .js: 1
  21. // }
  22. // }

getStats()

Count all *.js files recursively, ignoring node_modules but also include more detailed stats

  1. const saros = require("saros");
  2. saros
  3. .getStats({
  4. recursive: true,
  5. path: ".",
  6. ignore: ["node_modules"],
  7. extensions: [".js"],
  8. })
  9. .then((data) => {
  10. console.log(data);
  11. })
  12. .catch((err) => {
  13. console.log(err);
  14. });
  15. // Example output:
  16. // {
  17. // timeMs: 7,
  18. // numFiles: 1,
  19. // numLines: 14,
  20. // numUsedLines: 13,
  21. // numBlankLines: 1,
  22. // percentUsed: 0.9285714285714286,
  23. // percentBlank: 0.07142857142857142,
  24. // numFilesPerExtension: {
  25. // .js: 1
  26. // },
  27. // numLinesPerExtension: {
  28. // .js: 14
  29. // }
  30. // }

Prebuilt binaries

Use one of the binaries from the releases page.

Build from scratch

  1. npm run build

Will build a binary for your system and place it in release folder.

Test changes

  1. npm run lint
  2. npm test