Package Exports
- linguist-js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (linguist-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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'); // old import syntax
/*or*/
import linguist from 'linguist-js'; // modern import syntaxOr install globally using npm install -g linguist-js and run using the CLI command linguist.
linguist --helpUsage
Linguist contains one function which analyses a given folder.
As an example, take the following file structure:
.
| src
| | cli.js 1kB
| | index.ts 2kB
| readme.md 3kBRunning 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 },
"markup": {},
"data": {},
"prose": { "Markdown": 3000 }
}
}API
Node
const linguist = require('linguist-js');
let folder = './src';
let options = { keepVendored: false, checkAttributes: false };
let { count, results, languages } = linguist(folder, options);linguist(folder?, opts?)(default export): Analyse the language of all files found in a folder.folder(optional; string): The folder to analyse (defaults to./).opts(optional; object): An object containing analyser options.keepVendored(boolean): Whether to keep vendored files (dependencies, etc) (defaults tofalse).checkAttributes(boolean): Whether to check.gitattributesfor manual language classifications (defaults tofalse).
Command-line
linguist --analyze [<folder>] [--full] [--vendored] [--gitattributes]
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).--gitattributes(optional): Whether to check.gitattributesfiles for custom file associations (overrides).
--help: Display a help message.