Skip to content

Commit 4bced0e

Browse files
committed
2.8.0
1 parent 903da9e commit 4bced0e

File tree

5 files changed

+68
-147
lines changed

5 files changed

+68
-147
lines changed

changelog.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Changelog
22

3-
## Next
4-
- Added application of GitHub-Linguist override rule `linguist-detectable`.
5-
- Added line of code calculation to the output.
3+
## 2.8.0
4+
*2024-09-15*
5+
- Added checking of gitattributes override rule `linguist-detectable`.
6+
- Added lines of code totals to the output.
67
- Added option `checkDetected` to control the application of `linguist-detectable` overrides.
78
- Added option `calculateLines` (defaults to true) to control whether LOC calculations are performed.
89

package-lock.json

+54-135
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "linguist-js",
3-
"version": "2.7.1",
3+
"version": "2.8.0",
44
"description": "Analyse languages used in a folder. Powered by GitHub Linguist, although it doesn't need to be installed.",
55
"main": "dist/index.js",
66
"bin": {
@@ -38,11 +38,11 @@
3838
},
3939
"homepage": "https://github.com/Nixinova/Linguist#readme",
4040
"dependencies": {
41-
"binary-extensions": "^2.2.0 <3",
41+
"binary-extensions": "^2.3.0 <3",
4242
"commander": "^9.5.0 <10",
4343
"common-path-prefix": "^3.0.0",
4444
"cross-fetch": "^3.1.8 <4",
45-
"ignore": "^5.3.1",
45+
"ignore": "^5.3.2",
4646
"isbinaryfile": "^4.0.10 <5",
4747
"js-yaml": "^4.1.0",
4848
"node-cache": "^5.1.2"

src/index.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -438,15 +438,15 @@ async function analyse(rawPaths?: string | string[], opts: T.Options = {}): Prom
438438
results.files.lines.code += loc.code;
439439
// Add results to 'languages' section if language match found, or 'unknown' section otherwise
440440
if (lang) {
441-
// Add language and bytes data to corresponding section
442441
const { type } = langData[lang];
442+
// set default if unset
443443
results.languages.results[lang] ??= { type, bytes: 0, lines: { total: 0, content: 0, code: 0 }, color: langData[lang].color };
444+
// apply results to 'languages' section
444445
if (opts.childLanguages) {
445446
results.languages.results[lang].parent = langData[lang].group;
446447
}
447448
results.languages.results[lang].bytes += fileSize;
448449
results.languages.bytes += fileSize;
449-
// apply LOC calculations
450450
results.languages.results[lang].lines.total += loc.total;
451451
results.languages.results[lang].lines.content += loc.content;
452452
results.languages.results[lang].lines.code += loc.code;
@@ -456,8 +456,9 @@ async function analyse(rawPaths?: string | string[], opts: T.Options = {}): Prom
456456
}
457457
else {
458458
const ext = paths.extname(file);
459-
const unknownType = ext === '' ? 'filenames' : 'extensions';
460-
const name = ext === '' ? paths.basename(file) : ext;
459+
const unknownType = ext ? 'extensions' : 'filenames';
460+
const name = ext || paths.basename(file);
461+
// apply results to 'unknown' section
461462
results.unknown[unknownType][name] ??= 0;
462463
results.unknown[unknownType][name] += fileSize;
463464
results.unknown.bytes += fileSize;

test/expected.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"files": {
33
"count": 12,
4-
"bytes": 190,
5-
"lines": { "total": 25, "content": 15, "code": 10 },
4+
"bytes": 199,
5+
"lines": { "total": 27, "content": 16, "code": 11 },
66
"results": {
77
"~/al.al": "Perl",
88
"~/alternatives.asc": "AGS Script",

0 commit comments

Comments
 (0)