New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

linguist-js

Package Overview
Dependencies
Maintainers
0
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linguist-js - npm Package Compare versions

Comparing version 2.8.1 to 2.9.0

35

dist/cli.js

@@ -25,2 +25,3 @@ "use strict";

.option('-F|--listFiles [bool]', 'Whether to list every matching file under the language results', false)
.option('-m|--minSize <size>', 'Minimum size of file to show language results for (must have a unit: b, kb, mb, %, or loc)')
.option('-q|--quick [bool]', 'Skip complex language analysis (alias for -{A|I|H|S}=false)', false)

@@ -66,3 +67,35 @@ .option('-o|--offline [bool]', 'Use packaged data files instead of fetching latest from GitHub', false)

if (!args.json) {
const sortedEntries = Object.entries(languages.results).sort((a, b) => a[1].bytes < b[1].bytes ? +1 : -1);
// Ignore languages with a bytes/% size less than the declared min size
if (args.minSize) {
const totalSize = languages.bytes;
const minSizeAmt = parseFloat(args.minSize.replace(/[a-z]+$/i, '')); // '2KB' -> 2
const minSizeUnit = args.minSize.replace(/^\d+/, '').toLowerCase(); // '2KB' -> 'kb'
const checkBytes = minSizeUnit !== 'loc'; // whether to check bytes or loc
const conversionFactors = {
'b': n => n,
'kb': n => n * 1e3,
'mb': n => n * 1e6,
'%': n => n * totalSize / 100,
'loc': n => n,
};
const minBytesSize = conversionFactors[minSizeUnit](+minSizeAmt);
const other = { bytes: 0, lines: { total: 0, content: 0, code: 0 } };
// Apply specified minimums: delete language results that do not reach the threshold
for (const [lang, data] of Object.entries(languages.results)) {
const checkUnit = checkBytes ? data.bytes : data.lines.code;
if (checkUnit < minBytesSize) {
// Add to 'other' count
other.bytes += data.bytes;
other.lines.total += data.lines.total;
other.lines.content += data.lines.content;
other.lines.code += data.lines.code;
// Remove language result
delete languages.results[lang];
}
}
if (other.bytes) {
languages.results["Other"] = { ...other, type: null };
}
}
const sortedEntries = Object.entries(languages.results).sort((a, b) => (a[1].bytes < b[1].bytes ? +1 : -1));
const totalBytes = languages.bytes;

@@ -69,0 +102,0 @@ console.log(`\n Analysed ${files.bytes.toLocaleString()} B from ${files.count} files with linguist-js`);

2

dist/helpers/convert-pcre.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = pcre;
/** Convert a PCRE regex into JS. */

@@ -39,1 +38,2 @@ function pcre(regex) {

}
exports.default = pcre;

@@ -6,4 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseGeneratedDataFile = parseGeneratedDataFile;
exports.default = loadFile;
exports.parseGeneratedDataFile = void 0;
const fs_1 = __importDefault(require("fs"));

@@ -35,2 +34,3 @@ const path_1 = __importDefault(require("path"));

}
exports.parseGeneratedDataFile = parseGeneratedDataFile;
/** Load a data file from github-linguist. */

@@ -40,1 +40,2 @@ function loadFile(file, offline = false) {

}
exports.default = loadFile;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = parseAttributes;
const norm_path_1 = require("./norm-path");

@@ -38,1 +37,2 @@ /**

}
exports.default = parseAttributes;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = parseGitignore;
function parseGitignore(content) {

@@ -13,1 +12,2 @@ const readableData = content

}
exports.default = parseGitignore;

@@ -6,3 +6,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.default = readFileChunk;
const fs_1 = __importDefault(require("fs"));

@@ -25,1 +24,2 @@ /**

}
exports.default = readFileChunk;

@@ -6,3 +6,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.default = walk;
const fs_1 = __importDefault(require("fs"));

@@ -92,1 +91,2 @@ const path_1 = __importDefault(require("path"));

}
exports.default = walk;

@@ -49,3 +49,3 @@ "use strict";

opts = {
calculateLines: (_b = opts.calculateLines) !== null && _b !== void 0 ? _b : true, // default to true if unset
calculateLines: (_b = opts.calculateLines) !== null && _b !== void 0 ? _b : true,
checkIgnored: !opts.quick,

@@ -52,0 +52,0 @@ checkDetected: !opts.quick,

{
"name": "linguist-js",
"version": "2.8.1",
"version": "2.9.0",
"description": "Analyse languages used in a folder. Powered by GitHub Linguist, although it doesn't need to be installed.",

@@ -45,4 +45,4 @@ "main": "dist/index.js",

"common-path-prefix": "^3.0.0",
"cross-fetch": "^3.1.8 <4",
"ignore": "^5.3.2",
"cross-fetch": "^3.2.0 <4",
"ignore": "^7.0.3",
"isbinaryfile": "^4.0.10 <5",

@@ -49,0 +49,0 @@ "js-yaml": "^4.1.0",

@@ -53,7 +53,7 @@ [![Latest version](https://img.shields.io/github/v/release/Nixinova/Linguist?label=latest%20version&style=flat-square)](https://github.com/Nixinova/Linguist/releases)

"bytes": 6020,
"lines": {
"total": 100,
"content": 90,
"code": 80,
},
"lines": {
"total": 100,
"content": 90,
"code": 80,
},
"results": {

@@ -73,12 +73,32 @@ "/src/index.ts": "TypeScript",

"bytes": 6010,
"lines": {
"total": 90,
"content": 80,
"code": 70,
},
"lines": {
"total": 90,
"content": 80,
"code": 70,
},
"results": {
"JavaScript": { "type": "programming", "bytes": 1000, "lines": { "total": 49, "content": 49, "code": 44 }, "color": "#f1e05a" },
"Markdown": { "type": "prose", "bytes": 3000, "lines": { "total": 10, "content": 5, "code": 5 }, "color": "#083fa1" },
"Ruby": { "type": "programming", "bytes": 10, "lines": { "total": 1, "content": 1, "code": 1 }, "color": "#701516" },
"TypeScript": { "type": "programming", "bytes": 2000, "lines": { "total": 30, "content": 25, "code": 20 }, "color": "#2b7489" },
"JavaScript": {
"type": "programming",
"bytes": 1000,
"lines": { "total": 49, "content": 49, "code": 44 },
"color": "#f1e05a"
},
"Markdown": {
"type": "prose",
"bytes": 3000,
"lines": { "total": 10, "content": 5, "code": 5 },
"color": "#083fa1"
},
"Ruby": {
"type": "programming",
"bytes": 10,
"lines": { "total": 1, "content": 1, "code": 1 },
"color": "#701516"
},
"TypeScript": {
"type": "programming",
"bytes": 2000,
"lines": { "total": 30, "content": 25, "code": 20 },
"color": "#2b7489"
},
},

@@ -89,7 +109,7 @@ },

"bytes": 10,
"lines": {
"total": 10,
"content": 10,
"code": 10,
},
"lines": {
"total": 10,
"content": 10,
"code": 10,
},
"filenames": {

@@ -96,0 +116,0 @@ "no-lang": 10,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc