linguist-js 2.7.1 → 2.8.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.
Files changed (44) hide show
  1. package/dist/cli.js +5 -2
  2. package/dist/helpers/convert-pcre.js +1 -1
  3. package/dist/helpers/load-data.d.ts +1 -1
  4. package/dist/helpers/load-data.js +4 -5
  5. package/dist/helpers/parse-gitattributes.d.ts +1 -0
  6. package/dist/helpers/parse-gitattributes.js +6 -4
  7. package/dist/helpers/parse-gitignore.js +1 -1
  8. package/dist/helpers/read-file.d.ts +1 -1
  9. package/dist/helpers/read-file.js +2 -2
  10. package/dist/helpers/walk-tree.js +7 -2
  11. package/dist/index.js +73 -32
  12. package/dist/package.json +56 -0
  13. package/dist/src/cli.d.ts +1 -0
  14. package/dist/src/cli.js +146 -0
  15. package/dist/src/helpers/convert-pcre.d.ts +2 -0
  16. package/dist/src/helpers/convert-pcre.js +38 -0
  17. package/dist/src/helpers/load-data.d.ts +4 -0
  18. package/dist/src/helpers/load-data.js +37 -0
  19. package/dist/src/helpers/norm-path.d.ts +2 -0
  20. package/dist/src/helpers/norm-path.js +15 -0
  21. package/dist/src/helpers/parse-gitattributes.d.ts +17 -0
  22. package/dist/src/helpers/parse-gitattributes.js +37 -0
  23. package/dist/src/helpers/parse-gitignore.d.ts +1 -0
  24. package/dist/src/helpers/parse-gitignore.js +12 -0
  25. package/dist/src/helpers/read-file.d.ts +5 -0
  26. package/dist/src/helpers/read-file.js +23 -0
  27. package/dist/src/helpers/walk-tree.d.ts +20 -0
  28. package/dist/src/helpers/walk-tree.js +85 -0
  29. package/dist/src/index.d.ts +4 -0
  30. package/dist/src/index.js +485 -0
  31. package/dist/src/schema.d.ts +37 -0
  32. package/dist/src/schema.js +2 -0
  33. package/dist/src/types.d.ts +74 -0
  34. package/dist/src/types.js +2 -0
  35. package/dist/types.d.ts +22 -0
  36. package/dist/version.d.ts +2 -0
  37. package/dist/version.js +4 -0
  38. package/ext/documentation.yml +0 -3
  39. package/ext/generated.rb +5 -0
  40. package/ext/heuristics.yml +91 -16
  41. package/ext/languages.yml +317 -8
  42. package/ext/vendor.yml +0 -2
  43. package/package.json +6 -5
  44. package/readme.md +29 -5
package/readme.md CHANGED
@@ -50,6 +50,11 @@ Running LinguistJS on this folder will return the following JSON:
50
50
  "files": {
51
51
  "count": 5,
52
52
  "bytes": 6020,
53
+ "lines": {
54
+ "total": 100,
55
+ "content": 90,
56
+ "code": 80,
57
+ },
53
58
  "results": {
54
59
  "/src/index.ts": "TypeScript",
55
60
  "/src/cli.js": "JavaScript",
@@ -64,16 +69,26 @@ Running LinguistJS on this folder will return the following JSON:
64
69
  "languages": {
65
70
  "count": 3,
66
71
  "bytes": 6010,
72
+ "lines": {
73
+ "total": 90,
74
+ "content": 80,
75
+ "code": 70,
76
+ },
67
77
  "results": {
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" },
78
+ "JavaScript": { "type": "programming", "bytes": 1000, "lines": { "total": 49, "content": 49, "code": 44 }, "color": "#f1e05a" },
79
+ "Markdown": { "type": "prose", "bytes": 3000, "lines": { "total": 10, "content": 5, "code": 5 }, "color": "#083fa1" },
80
+ "Ruby": { "type": "programming", "bytes": 10, "lines": { "total": 1, "content": 1, "code": 1 }, "color": "#701516" },
81
+ "TypeScript": { "type": "programming", "bytes": 2000, "lines": { "total": 30, "content": 25, "code": 20 }, "color": "#2b7489" },
72
82
  },
73
83
  },
74
84
  "unknown": {
75
85
  "count": 1,
76
86
  "bytes": 10,
87
+ "lines": {
88
+ "total": 10,
89
+ "content": 10,
90
+ "code": 10,
91
+ },
77
92
  "filenames": {
78
93
  "no-lang": 10,
79
94
  },
@@ -127,9 +142,11 @@ const { files, languages, unknown } = await linguist(fileNames, { fileContent, .
127
142
  Whether to display sub-languages instead of their parents when possible (defaults to `false`).
128
143
  - `quick` (boolean):
129
144
  Whether to skip complex language analysis such as the checking of heuristics and gitattributes statements (defaults to `false`).
130
- Alias for `checkAttributes:false, checkIgnored:false, checkHeuristics:false, checkShebang:false, checkModeline:false`.
145
+ Alias for `checkAttributes:false, checkIgnored:false, checkDetected:false, checkHeuristics:false, checkShebang:false, checkModeline:false`.
131
146
  - `offline` (boolean):
132
147
  Whether to use pre-packaged metadata files instead of fetching them from GitHub at runtime (defaults to `false`).
148
+ - `calculateLines` (boolean):
149
+ Whether to calculate line of code totals (defaults to `true`).
133
150
  - `keepVendored` (boolean):
134
151
  Whether to keep vendored files (dependencies, etc) (defaults to `false`).
135
152
  Does nothing when `fileContent` is set.
@@ -143,6 +160,8 @@ const { files, languages, unknown } = await linguist(fileNames, { fileContent, .
143
160
  - `checkIgnored` (boolean):
144
161
  Force the checking of `.gitignore` files (defaults to `true` unless `quick` is set).
145
162
  Does nothing when `fileContent` is set.
163
+ - `checkDetected` (boolean):
164
+ Force files marked with `linguist-detectable` to show up in the output, even if the file is not part of the declared `categories`.
146
165
  - `checkHeuristics` (boolean):
147
166
  Apply heuristics to ambiguous languages (defaults to `true` unless `quick` is set).
148
167
  - `checkShebang` (boolean):
@@ -187,6 +206,8 @@ linguist --version
187
206
  Alias for `--checkAttributes=false --checkIgnored=false --checkHeuristics=false --checkShebang=false --checkModeline=false`.
188
207
  - `--offline`:
189
208
  Use pre-packaged metadata files instead of fetching them from GitHub at runtime.
209
+ - `--calculateLines`:
210
+ Calculate line of code totals from files.
190
211
  - `--keepVendored`:
191
212
  Include vendored files (auto-generated files, dependencies folder, etc) in the output.
192
213
  - `--keepBinary`:
@@ -199,6 +220,9 @@ linguist --version
199
220
  - `--checkIgnored`:
200
221
  Force the checking of `.gitignore` files.
201
222
  Use alongside `--quick` to override it disabling this option.
223
+ - `--checkDetected`:
224
+ Force files marked with `linguist-detectable` to show up in the output, even if the file is not part of the declared `--categories`.
225
+ Use alongside `--quick` to override it disabling this option.
202
226
  - `--checkHeuristics`:
203
227
  Apply heuristics to ambiguous languages.
204
228
  Use alongside `--quick` to override it disabling this option.