Skip to content

Commit

Permalink
2.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nixinova committed Sep 15, 2024
1 parent 903da9e commit 4bced0e
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 147 deletions.
7 changes: 4 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Changelog

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

Expand Down
189 changes: 54 additions & 135 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "linguist-js",
"version": "2.7.1",
"version": "2.8.0",
"description": "Analyse languages used in a folder. Powered by GitHub Linguist, although it doesn't need to be installed.",
"main": "dist/index.js",
"bin": {
Expand Down Expand Up @@ -38,11 +38,11 @@
},
"homepage": "https://github.com/Nixinova/Linguist#readme",
"dependencies": {
"binary-extensions": "^2.2.0 <3",
"binary-extensions": "^2.3.0 <3",
"commander": "^9.5.0 <10",
"common-path-prefix": "^3.0.0",
"cross-fetch": "^3.1.8 <4",
"ignore": "^5.3.1",
"ignore": "^5.3.2",
"isbinaryfile": "^4.0.10 <5",
"js-yaml": "^4.1.0",
"node-cache": "^5.1.2"
Expand Down
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,15 @@ async function analyse(rawPaths?: string | string[], opts: T.Options = {}): Prom
results.files.lines.code += loc.code;
// Add results to 'languages' section if language match found, or 'unknown' section otherwise
if (lang) {
// Add language and bytes data to corresponding section
const { type } = langData[lang];
// set default if unset
results.languages.results[lang] ??= { type, bytes: 0, lines: { total: 0, content: 0, code: 0 }, color: langData[lang].color };
// apply results to 'languages' section
if (opts.childLanguages) {
results.languages.results[lang].parent = langData[lang].group;
}
results.languages.results[lang].bytes += fileSize;
results.languages.bytes += fileSize;
// apply LOC calculations
results.languages.results[lang].lines.total += loc.total;
results.languages.results[lang].lines.content += loc.content;
results.languages.results[lang].lines.code += loc.code;
Expand All @@ -456,8 +456,9 @@ async function analyse(rawPaths?: string | string[], opts: T.Options = {}): Prom
}
else {
const ext = paths.extname(file);
const unknownType = ext === '' ? 'filenames' : 'extensions';
const name = ext === '' ? paths.basename(file) : ext;
const unknownType = ext ? 'extensions' : 'filenames';
const name = ext || paths.basename(file);
// apply results to 'unknown' section
results.unknown[unknownType][name] ??= 0;
results.unknown[unknownType][name] += fileSize;
results.unknown.bytes += fileSize;
Expand Down
4 changes: 2 additions & 2 deletions test/expected.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"files": {
"count": 12,
"bytes": 190,
"lines": { "total": 25, "content": 15, "code": 10 },
"bytes": 199,
"lines": { "total": 27, "content": 16, "code": 11 },
"results": {
"~/al.al": "Perl",
"~/alternatives.asc": "AGS Script",
Expand Down

0 comments on commit 4bced0e

Please sign in to comment.