linguist-js
Advanced tools
Comparing version 1.8.1 to 1.8.2
@@ -8,22 +8,20 @@ "use strict"; | ||
const path_1 = __importDefault(require("path")); | ||
const glob_to_regexp_1 = __importDefault(require("glob-to-regexp")); | ||
const allFiles = new Set(); | ||
const allFolders = new Set(); | ||
/** Generate list of files in a directory. */ | ||
function walk(folder, ignoredGlobs = []) { | ||
const ignored = ignoredGlobs.map(glob => (0, glob_to_regexp_1.default)(glob, { extended: true })); | ||
function walk(folder, ignored = []) { | ||
if (Array.isArray(folder)) { | ||
for (const path of folder) | ||
walk(path, ignoredGlobs); | ||
walk(path, ignored); | ||
} | ||
else { | ||
allFolders.add(folder.replace(/\\/g, '/')); | ||
const files = fs_1.default.readdirSync(folder); | ||
for (const file of files) { | ||
if (ignored.some(pattern => pattern.test(file))) | ||
const path = path_1.default.resolve(folder, file).replace(/\\/g, '/'); | ||
if (ignored.some(pattern => pattern.test(path))) | ||
continue; | ||
const path = path_1.default.resolve(folder, file); | ||
allFolders.add(folder.replace(/\\/g, '/')); | ||
if (fs_1.default.lstatSync(path).isDirectory()) { | ||
allFolders.add(path.replace(/\\/g, '/')); | ||
walk(path); | ||
walk(path, ignored); | ||
continue; | ||
@@ -30,0 +28,0 @@ } |
@@ -36,5 +36,5 @@ "use strict"; | ||
const ignoredFiles = [ | ||
'.git', | ||
opts.keepVendored ? vendorData.map(path => (0, convert_pcre_1.default)(path).source) : [], | ||
(_b = (_a = opts.ignore) === null || _a === void 0 ? void 0 : _a.map(path => (0, glob_to_regexp_1.default)('*' + path + '*', { extended: true }).source)) !== null && _b !== void 0 ? _b : [], | ||
/\/\.git\//, | ||
opts.keepVendored ? [] : vendorData.map(path => (0, convert_pcre_1.default)(path)), | ||
(_b = (_a = opts.ignore) === null || _a === void 0 ? void 0 : _a.map(path => (0, glob_to_regexp_1.default)('*' + path + '*', { extended: true }))) !== null && _b !== void 0 ? _b : [], | ||
].flat(); | ||
@@ -41,0 +41,0 @@ let { files, folders } = (0, walk_tree_1.default)(input !== null && input !== void 0 ? input : '.', ignoredFiles); |
{ | ||
"name": "linguist-js", | ||
"version": "1.8.1", | ||
"version": "1.8.2", | ||
"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", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30539
489