Linguist
Analyses all files located in a given folder and collates the results.
Powered by github-linguist, although it doesn't need to be installed.
Install
Linguist is available on npm as linguist-js
.
Install locally using npm install linguist-js
and import it into your code like so:
const linguist = require('linguist-js');
import linguist from 'linguist-js';
Or install globally using npm install -g linguist-js
and run using the CLI command linguist
.
linguist --help
Usage
Linguist contains one function which analyses a given folder.
As an example, take the following file structure:
.
| src
| | index.ts 2kB
| | cli.js 1kB
| readme.md 5kB
Running Linguist on this folder will return the following JSON:
{
"count": 3,
"results": {
"src/index.ts": "TypeScript",
"src/cli.js": "JavaScript",
"readme.md": "Markdown"
},
"languages": {
"programming": {
"JavaScript": 1000,
"TypeScript": 2000,
"Markdown": 5000
}
}
}
API
Node
const linguist = require('linguist-js');
let folder = './src';
let options = { keepVendored: false };
let { count, results, languages } = linguist(folder, options);
Command-line
linguist --analyze [<folder>] [--full] [--vendored]
linguist --help
--analyze
: Analyse the language of all files found in a folder.
<folder>
(optional): The folder to analyse (defaults to ./
).--full
(optional): Whether to print a full list of all files analysed.--vendored
(optional): Whether to include vendored files (dependencies, etc).
--help
: Display a help message.