linguist-js 2.5.6 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linguist-js",
3
- "version": "2.5.6",
3
+ "version": "2.6.1",
4
4
  "description": "Analyse languages used in a folder. Powered by GitHub Linguist, although it doesn't need to be installed.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -12,14 +12,13 @@
12
12
  },
13
13
  "scripts": {
14
14
  "download-files": "npx tsx@3 build/download-files",
15
- "pre-publish": "npm run download-files && npm test && npm run test:perf",
16
- "test:perf": "tsc && node test/perf",
15
+ "pre-publish": "npm run download-files && npm test && npm run perf",
16
+ "perf": "tsc && node test/perf",
17
17
  "test": "tsc && node test/folder && echo --- && node test/unit"
18
18
  },
19
19
  "files": [
20
20
  "bin/",
21
- "dist/**/*.js",
22
- "dist/*.d.ts",
21
+ "dist/",
23
22
  "ext/"
24
23
  ],
25
24
  "repository": {
@@ -42,7 +41,7 @@
42
41
  "binary-extensions": "^2.2.0",
43
42
  "commander": "^9.5.0 <10",
44
43
  "common-path-prefix": "^3.0.0",
45
- "cross-fetch": "^3.1.6",
44
+ "cross-fetch": "^3.1.8 <4",
46
45
  "ignore": "^5.2.4",
47
46
  "isbinaryfile": "^4.0.10 <5",
48
47
  "js-yaml": "^4.1.0",
@@ -52,6 +51,6 @@
52
51
  "@types/js-yaml": "^4.0.5",
53
52
  "@types/node": "ts5.0",
54
53
  "deep-object-diff": "^1.1.9",
55
- "typescript": "^5.1"
54
+ "typescript": "~5.0.4 <5.1"
56
55
  }
57
56
  }
package/readme.md CHANGED
@@ -4,13 +4,14 @@
4
4
 
5
5
  # LinguistJS
6
6
 
7
- Analyses the languages of all files in a given folder and collates the results.
7
+ Analyses the languages of all files in a given folder or folders and collates the results.
8
8
 
9
9
  Powered by [github-linguist](https://github.com/github/linguist), although it doesn't need to be installed.
10
10
 
11
11
  ## Install
12
12
 
13
- [Node.js](https://nodejs.org) must be installed to be able to use this.
13
+ [Node.js](https://nodejs.org) must be installed to be able to use LinguistJS.
14
+
14
15
  LinguistJS is available [on npm](https://npmjs.com/package/linguist-js) as `linguist-js`.
15
16
 
16
17
  Install locally using `npm install linguist-js` and import it into your code like so:
@@ -19,15 +20,16 @@ Install locally using `npm install linguist-js` and import it into your code lik
19
20
  const linguist = require('linguist-js');
20
21
  ```
21
22
 
22
- Or install globally using `npm install -g linguist-js` and run using the CLI command `linguist`.
23
+ Or install globally using `npm install -g linguist-js` and run using the CLI command `linguist` or `linguist-js`.
23
24
 
24
25
  ```
25
26
  linguist --help
27
+ linguist-js --help
26
28
  ```
27
29
 
28
30
  ## Usage
29
31
 
30
- LinguistJS contains one function which analyses a given folder.
32
+ LinguistJS contains one function which analyses a given folder or folders.
31
33
 
32
34
  As an example, take the following file structure:
33
35
 
@@ -38,6 +40,7 @@ As an example, take the following file structure:
38
40
  | | index.ts 2kB
39
41
  | readme.md 3kB
40
42
  | no-lang 10B
43
+ | x.pluginspec 10B
41
44
  ```
42
45
 
43
46
  Running LinguistJS on this folder will return the following JSON:
@@ -45,22 +48,27 @@ Running LinguistJS on this folder will return the following JSON:
45
48
  ```json
46
49
  {
47
50
  "files": {
48
- "count": 4,
49
- "bytes": 6010,
51
+ "count": 5,
52
+ "bytes": 6020,
50
53
  "results": {
51
54
  "/src/index.ts": "TypeScript",
52
55
  "/src/cli.js": "JavaScript",
53
56
  "/readme.md": "Markdown",
54
57
  "/no-lang": null,
55
- }
58
+ "/x.pluginspec": "Ruby",
59
+ },
60
+ "alternatives": {
61
+ "/x.pluginspec": ["XML"],
62
+ },
56
63
  },
57
64
  "languages": {
58
65
  "count": 3,
59
- "bytes": 6000,
66
+ "bytes": 6010,
60
67
  "results": {
61
- "JavaScript": { "type": "programming", "bytes": 1000, "color": "#f1e05a" },
62
- "TypeScript": { "type": "programming", "bytes": 2000, "color": "#2b7489" },
63
- "Markdown": { "type": "prose", "bytes": 3000, "color": "#083fa1" },
68
+ "JavaScript": { "type": "programming", "bytes": 1000, "color": "#f1e05a" },
69
+ "Markdown": { "type": "prose", "bytes": 3000, "color": "#083fa1" },
70
+ "Ruby": { "type": "programming", "bytes": 10, "color": "#701516" },
71
+ "TypeScript": { "type": "programming", "bytes": 2000, "color": "#2b7489" },
64
72
  },
65
73
  },
66
74
  "unknown": {
@@ -93,7 +101,7 @@ const { files, languages, unknown } = linguist(folder, options);
93
101
  ```
94
102
 
95
103
  - `linguist(entry?, opts?)` (default export):
96
- Analyse the language of all files found in a folder.
104
+ Analyse the language of all files found in a folder or folders.
97
105
  - `entry` (optional; string or string array):
98
106
  The folder(s) to analyse (defaults to `./`).
99
107
  - `opts` (optional; object):
@@ -137,50 +145,56 @@ const { files, languages, unknown } = linguist(folder, options);
137
145
  ### Command-line
138
146
 
139
147
  ```
140
- linguist --analyze [<folder>] [<...options>]
148
+ linguist --analyze [<folders...>] [<options...>]
141
149
  linguist --help
150
+ linguist --version
142
151
  ```
143
152
 
144
153
  - `--analyze`:
145
- Analyse the language of all files found in a folder.
146
- - `<folders...>`:
154
+ Analyse the language of all files found in a folder or folders.
155
+ - `[<folders...>]`:
147
156
  The folders to analyse (defaults to `./`).
148
- - `--ignoredFiles <glob1> [[--ignoredFiles] <glob2> ...]`:
157
+ - `--ignoredFiles <globs...>`:
149
158
  A list of file path globs to ignore.
150
- When specifying more than one glob, this option can either be called with multiple values given (e.g., `--ignoredFiles *.txt *.json`) or be called multiple times (e.g., `--ignoredFiles *.txt --ignoredFiles *.json`). Both ways are equivalent.
151
- - `--ignoredLanguages`:
152
- A list of languages to ignore.
159
+ - `--ignoredLanguages <languages...>`:
160
+ A list of languages to exclude from the output.
153
161
  - `--categories <categories...>`:
154
- A list of space-delimited categories that should be displayed in the output.
162
+ A list of language categories that should be displayed in the output.
163
+ Must be one or more of `data`, `prose`, `programming`, `markup`.
155
164
  - `--childLanguages`:
156
- Whether to display sub-languages instead of their parents, when possible.
165
+ Display sub-languages instead of their parents, when possible.
157
166
  - `--json`:
158
167
  Display the outputted language data as JSON.
159
168
  - `--tree <traversal>`:
160
169
  A dot-delimited traversal to the nested object that should be logged to the console instead of the entire output.
161
170
  Requires `--json` to be specified.
162
171
  - `--quick`:
163
- Whether to skip the checking of `.gitattributes` and `.gitignore` files for manual language classifications.
172
+ Skip the checking of `.gitattributes` and `.gitignore` files for manual language classifications.
164
173
  Alias for `--checkAttributes=false --checkIgnored=false --checkHeuristics=false --checkShebang=false --checkModeline=false`.
165
174
  - `--offline`:
166
175
  Use pre-packaged metadata files instead of fetching them from GitHub at runtime.
167
176
  - `--keepVendored`:
168
- Whether to include vendored files (auto-generated files, dependencies folder, etc).
177
+ Include vendored files (auto-generated files, dependencies folder, etc) in the output.
169
178
  - `--keepBinary`:
170
- Whether binary files should be excluded from the output.
179
+ Include binary files in the output.
171
180
  - `--relativePaths`:
172
181
  Change the absolute file paths in the output to be relative to the current working directory.
173
182
  - `--checkAttributes`:
174
- Force the checking of `.gitatributes` files (use alongside `--quick` to overwrite).
183
+ Force the checking of `.gitatributes` files.
184
+ Use alongside `--quick` to override it disabling this option.
175
185
  - `--checkIgnored`:
176
- Force the checking of `.gitignore` files (use alongside `--quick` to overwrite).
186
+ Force the checking of `.gitignore` files.
187
+ Use alongside `--quick` to override it disabling this option.
177
188
  - `--checkHeuristics`:
178
- Apply heuristics to ambiguous languages (use alongside `--quick` to overwrite).
189
+ Apply heuristics to ambiguous languages.
190
+ Use alongside `--quick` to override it disabling this option.
179
191
  - `--checkShebang`:
180
- Check shebang (`#!`) lines for explicit classification (use alongside `--quick` to overwrite).
192
+ Check shebang (`#!`) lines for explicit classification.
193
+ Use alongside `--quick` to override it disabling this option.
181
194
  - `--checkModeline`:
182
- Check modelines for explicit classification (use alongside `--quick` to overwrite).
195
+ Check modelines for explicit classification.
196
+ Use alongside `--quick` to override it disabling this option.
183
197
  - `--help`:
184
- Display a help message.
198
+ Display the help message.
185
199
  - `--version`:
186
- Display the current version of linguist-js.
200
+ Display the current installed version of LinguistJS.