codeql-action/node_modules/github-linguist
Andrew Eisenberg ddcb299283 Update loc count library
This version will count lines of code in each file serially. It still
runs all file system operations asynchronously. The only difference now
is that it will only count one file at a time. It is slower, but it
is able to count large repositories without running out of memory.
2021-05-12 16:33:05 -07:00
..
.github/workflows Add the github-linguist package 2021-04-22 15:59:49 -07:00
.vscode Avoid analyzing excluded language files for line counting 2021-04-28 16:07:55 -07:00
dist Update loc count library 2021-05-12 16:33:05 -07:00
node_modules Add the github-linguist package 2021-04-22 15:59:49 -07:00
src Update loc count library 2021-05-12 16:33:05 -07:00
.eslintignore Add the github-linguist package 2021-04-22 15:59:49 -07:00
.eslintrc.js Add the github-linguist package 2021-04-22 15:59:49 -07:00
.prettierrc.js Add the github-linguist package 2021-04-22 15:59:49 -07:00
package.json Update loc count library 2021-05-12 16:33:05 -07:00
README.md Add the github-linguist package 2021-04-22 15:59:49 -07:00
tsconfig.json Add the github-linguist package 2021-04-22 15:59:49 -07:00

github-linguist

💻 Counts the number of lines of code, written in TypeScript.

Warning: This package uses regular expressions to approximate the lines of code in a project. The results are not 100% precise because the regular expressions can return mistakes in edge cases, for example if comment tokens are present inside of multiline strings.

Prerequisites

  • Node.js 6+

Install

npm install github-linguist

or

yarn add github-linguist

Usage

You can use loc in you ternimal, or as a npm package in your projects.

Command line mode

Supports counting lines of code of a file or directory.

1. Lines of code in a single file

# loc file <path>
loc file src/index.ts

loc file

2. Lines of code in a directory

# loc <pattern>
loc dir **/*.ts

loc dir

Third-party mode

import { LocFile, LocDir } from 'github-linguist';

// for a file.
const file = new LocFile(filePath);
const { info } = file.getInfo();

//  for a directory.
const dir = new LocDir({
  cwd: // root directory, or leave blank to use process.cwd()
  include: // string or string[] containing path patterns to include (default include all)
  exclude: // string or string[] containing path patterns to exclude (default exclude none)
});
const { info } = dir.getInfo();

License

MIT License.