Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

linguist-js

Package Overview
Dependencies
Maintainers
1
Versions
65
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.5.0 to 2.5.1

4

dist/helpers/load-data.js

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

Object.defineProperty(exports, "__esModule", { value: true });
const promises_1 = __importDefault(require("fs/promises"));
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));

@@ -25,3 +25,3 @@ const cross_fetch_1 = __importDefault(require("cross-fetch"));

const filePath = path_1.default.resolve(__dirname, '../../ext', file);
return promises_1.default.readFile(filePath).then(buffer => buffer.toString());
return fs_1.default.promises.readFile(filePath).then(buffer => buffer.toString());
}

@@ -28,0 +28,0 @@ /** Load a data file from github-linguist. */

@@ -17,4 +17,4 @@ "use strict";

async function analyse(input, opts = {}) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
var _t, _u, _v;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
var _u, _v, _w;
const useRawContent = opts.fileContent !== undefined;

@@ -273,4 +273,12 @@ input = [input !== null && input !== void 0 ? input : []].flat();

normalise(heuristicsData.named_patterns[heuristic.named_pattern]);
if (heuristic.and) {
for (const data of heuristic.and) {
if (data.pattern)
normalise(data.pattern);
if (data.named_pattern)
normalise(heuristicsData.named_patterns[data.named_pattern]);
}
}
// Check file contents and apply heuristic patterns
const fileContent = opts.fileContent ? opts.fileContent[files.indexOf(file)] : await (0, read_file_1.default)(file).catch(() => null);
const fileContent = ((_l = opts.fileContent) === null || _l === void 0 ? void 0 : _l.length) ? opts.fileContent[files.indexOf(file)] : await (0, read_file_1.default)(file).catch(() => null);
if (fileContent === null)

@@ -285,6 +293,6 @@ continue;

// If no heuristics, assign a language
(_l = (_t = results.files.results)[file]) !== null && _l !== void 0 ? _l : (_t[file] = fileAssociations[file][0]);
(_m = (_u = results.files.results)[file]) !== null && _m !== void 0 ? _m : (_u[file] = fileAssociations[file][0]);
}
// Skip specified categories
if ((_m = opts.categories) === null || _m === void 0 ? void 0 : _m.length) {
if ((_o = opts.categories) === null || _o === void 0 ? void 0 : _o.length) {
const categories = ['data', 'markup', 'programming', 'prose'];

@@ -325,3 +333,3 @@ const hiddenCategories = categories.filter(cat => !opts.categories.includes(cat));

continue;
const fileSize = (_q = (_p = (_o = opts.fileContent) === null || _o === void 0 ? void 0 : _o[files.indexOf(file)]) === null || _p === void 0 ? void 0 : _p.length) !== null && _q !== void 0 ? _q : fs_1.default.statSync(file).size;
const fileSize = (_r = (_q = (_p = opts.fileContent) === null || _p === void 0 ? void 0 : _p[files.indexOf(file)]) === null || _q === void 0 ? void 0 : _q.length) !== null && _r !== void 0 ? _r : fs_1.default.statSync(file).size;
results.files.bytes += fileSize;

@@ -333,3 +341,3 @@ // If no language found, add extension in other section

const name = ext === '' ? path_1.default.basename(file) : ext;
(_r = (_u = results.unknown[unknownType])[name]) !== null && _r !== void 0 ? _r : (_u[name] = 0);
(_s = (_v = results.unknown[unknownType])[name]) !== null && _s !== void 0 ? _s : (_v[name] = 0);
results.unknown[unknownType][name] += fileSize;

@@ -341,3 +349,3 @@ results.unknown.bytes += fileSize;

const { type } = langData[lang];
(_s = (_v = results.languages.results)[lang]) !== null && _s !== void 0 ? _s : (_v[lang] = { type, bytes: 0, color: langData[lang].color });
(_t = (_w = results.languages.results)[lang]) !== null && _t !== void 0 ? _t : (_w[lang] = { type, bytes: 0, color: langData[lang].color });
if (opts.childLanguages) {

@@ -344,0 +352,0 @@ results.languages.results[lang].parent = langData[lang].group;

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

@@ -43,3 +43,3 @@ "main": "dist/index.js",

"binary-extensions": "^2.2.0",
"commander": "^9.2.0",
"commander": "^9.3.0",
"common-path-prefix": "^3.0.0",

@@ -53,8 +53,7 @@ "cross-fetch": "^3.1.5",

"devDependencies": {
"@types/glob-to-regexp": "ts4.6",
"@types/js-yaml": "ts4.6",
"@types/node": "ts4.6",
"@types/js-yaml": "^4.0.5",
"@types/node": "ts4.7",
"deep-object-diff": "^1.1.7",
"typescript": "~4.6.4"
"typescript": "~4.7.4"
}
}

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

- File paths in the output use only forward slashes as delimiters, even on Windows.
- This tool does not work when offline.
- Do not rely on any language classification output from LinguistJS being unchanged between runs.

@@ -83,0 +82,0 @@ Language data is fetched each run from the latest classifications of [`github-linguist`](https://github.com/github/linguist).

Sorry, the diff of this file is not supported yet

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