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.3.0 to 2.3.1

11

dist/helpers/convert-pcre.js

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

let finalRegex = regex;
const replace = (search, replace) => finalRegex = finalRegex.replace(search, replace);
const finalFlags = new Set();

@@ -12,10 +13,11 @@ // Convert inline flag declarations

for (const [match, flags] of [...inlineMatches, ...startMatches]) {
finalRegex = finalRegex.replace(match, '');
replace(match, '');
[...flags].forEach(flag => finalFlags.add(flag));
}
// Remove invalid modifiers
finalRegex = finalRegex.replace(/([*+]){2}/g, '$1');
// Remove invalid syntax
replace(/([*+]){2}/g, '$1');
replace(/\(\?>/g, '(?:');
// Remove start/end-of-file markers
if (/\\[AZ]/.test(finalRegex)) {
finalRegex = finalRegex.replace(/\\A/g, '^').replace(/\\Z/g, '$');
replace(/\\A/g, '^').replace(/\\Z/g, '$');
finalFlags.delete('m');

@@ -25,4 +27,5 @@ }

finalFlags.add('m');
// Return final regex
return RegExp(finalRegex, [...finalFlags].join(''));
}
exports.default = pcre;

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

async function analyse(input, opts = {}) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
var _r, _s, _t;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
var _s, _t, _u;
const useRawContent = opts.fileContent !== undefined;
const langData = await (0, load_data_1.default)('languages.yml').then(js_yaml_1.default.load);

@@ -63,3 +64,3 @@ const vendorData = await (0, load_data_1.default)('vendor.yml').then(js_yaml_1.default.load);

const customText = [];
if (!opts.fileContent && !opts.quick) {
if (!useRawContent && !opts.quick) {
for (const folder of folders) {

@@ -111,3 +112,3 @@ // Skip if folder is marked in gitattributes

// Check vendored files
if (!opts.fileContent && !opts.keepVendored) {
if (!useRawContent && !opts.keepVendored) {
// Filter out any files that match a vendor file path

@@ -125,3 +126,3 @@ const matcher = (match) => RegExp(match.replace(/\/$/, '/.+$').replace(/^\.\//, ''));

fileAssociations[file].push(parent || result);
extensions[file] = path_1.default.extname(file);
extensions[file] = path_1.default.extname(file).toLowerCase();
};

@@ -154,3 +155,3 @@ const overridesArray = Object.entries(overrides);

// Check override for manual language classification
if (!opts.fileContent && !opts.quick && opts.checkAttributes) {
if (!useRawContent && !opts.quick && opts.checkAttributes) {
const match = overridesArray.find(item => RegExp(item[0]).test(file));

@@ -187,3 +188,3 @@ if (match) {

// Skip binary files
if (!opts.fileContent && !opts.keepBinary) {
if (!useRawContent && !opts.keepBinary) {
const isCustomText = customText.some(path => RegExp(path).test(file));

@@ -210,4 +211,5 @@ const isCustomBinary = customBinary.some(path => RegExp(path).test(file));

// Make sure the results includes this language
const languageGroup = (_j = langData[heuristic.language]) === null || _j === void 0 ? void 0 : _j.group;
const matchesLang = fileAssociations[file].includes(heuristic.language);
const matchesParent = langData[heuristic.language].group && fileAssociations[file].includes(langData[heuristic.language].group);
const matchesParent = languageGroup && fileAssociations[file].includes(languageGroup);
if (!matchesLang && !matchesParent)

@@ -233,6 +235,6 @@ continue;

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

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

// Convert paths to relative
if (!opts.fileContent && opts.relativePaths) {
if (!useRawContent && opts.relativePaths) {
const newMap = {};

@@ -270,3 +272,3 @@ for (const [file, lang] of Object.entries(results.files.results)) {

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

@@ -278,3 +280,3 @@ // If no language found, add extension in other section

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

@@ -286,3 +288,3 @@ results.unknown.bytes += fileSize;

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

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

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

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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