@cjser/globby 16.2.1-cjser.2 → 16.2.3-cjser.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjser/index.cjs +278 -61
- package/ignore.js +172 -24
- package/index.js +63 -36
- package/package.json +3 -3
- package/readme.md +1 -1
- package/utilities.js +217 -35
package/dist-cjser/index.cjs
CHANGED
|
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
|
|
29
|
-
// packages/@cjser/globby.tmp-26-
|
|
29
|
+
// packages/@cjser/globby.tmp-26-1786379054379/index.js
|
|
30
30
|
var index_exports = {};
|
|
31
31
|
__export(index_exports, {
|
|
32
32
|
convertPathToPattern: () => convertPathToPattern,
|
|
@@ -50,24 +50,26 @@ var import_sindresorhus_merge_streams = __toESM(require("@cjser/sindresorhus__me
|
|
|
50
50
|
var import_fast_glob3 = __toESM(require("fast-glob"), 1);
|
|
51
51
|
var import_node2 = require("@cjser/unicorn-magic/node");
|
|
52
52
|
|
|
53
|
-
// packages/@cjser/globby.tmp-26-
|
|
53
|
+
// packages/@cjser/globby.tmp-26-1786379054379/ignore.js
|
|
54
54
|
var import_node_process = __toESM(require("node:process"), 1);
|
|
55
55
|
var import_node_fs2 = __toESM(require("node:fs"), 1);
|
|
56
56
|
var import_promises = __toESM(require("node:fs/promises"), 1);
|
|
57
57
|
var import_node_path2 = __toESM(require("node:path"), 1);
|
|
58
58
|
var import_node_os = __toESM(require("node:os"), 1);
|
|
59
59
|
var import_fast_glob2 = __toESM(require("fast-glob"), 1);
|
|
60
|
-
var
|
|
60
|
+
var import_ignore2 = __toESM(require("ignore"), 1);
|
|
61
61
|
var import_is_path_inside2 = __toESM(require("@cjser/is-path-inside"), 1);
|
|
62
|
-
var
|
|
62
|
+
var import_slash2 = __toESM(require("@cjser/slash"), 1);
|
|
63
63
|
var import_node = require("@cjser/unicorn-magic/node");
|
|
64
64
|
|
|
65
|
-
// packages/@cjser/globby.tmp-26-
|
|
65
|
+
// packages/@cjser/globby.tmp-26-1786379054379/utilities.js
|
|
66
66
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
67
67
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
68
68
|
var import_node_util = require("node:util");
|
|
69
69
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
70
|
+
var import_ignore = __toESM(require("ignore"), 1);
|
|
70
71
|
var import_is_path_inside = __toESM(require("@cjser/is-path-inside"), 1);
|
|
72
|
+
var import_slash = __toESM(require("@cjser/slash"), 1);
|
|
71
73
|
var isNegativePattern = (pattern) => pattern[0] === "!";
|
|
72
74
|
var normalizeAbsolutePatternToRelative = (pattern) => {
|
|
73
75
|
if (!pattern.startsWith("/")) {
|
|
@@ -268,23 +270,121 @@ var getParentGitignorePaths = (gitRoot, cwd) => {
|
|
|
268
270
|
const chain = buildPathChain(import_node_path.default.resolve(cwd), import_node_path.default.resolve(gitRoot));
|
|
269
271
|
return [...chain].reverse().map((directory) => import_node_path.default.join(directory, ".gitignore"));
|
|
270
272
|
};
|
|
271
|
-
var
|
|
272
|
-
|
|
273
|
-
|
|
273
|
+
var GITIGNORE_WILDCARDS = /(?<!\\)[*?[]/u;
|
|
274
|
+
var hasGitignoreWildcards = (value) => GITIGNORE_WILDCARDS.test(value);
|
|
275
|
+
var MICROMATCH_ONLY_SYNTAX = /[(){}|\\]/u;
|
|
276
|
+
var unescapeGitignorePattern = (value) => value.replaceAll(/\\(.)/gu, "$1");
|
|
277
|
+
var normalizeGitignorePatternForIgnore = (value) => value.replaceAll(/\\(.)/gu, (match, character) => "*[]\\".includes(character) ? match : character);
|
|
278
|
+
var toLiteralPattern = (value) => import_fast_glob.default.escapePath(unescapeGitignorePattern(value));
|
|
279
|
+
var finalSegment = (value) => value.replace(/\/+$/u, "").split("/").pop();
|
|
280
|
+
var toStandaloneRule = (value) => value.replace(/^([#!])/u, String.raw`\$1`);
|
|
281
|
+
var isInsideCwd = (relativePath) => relativePath !== "" && !relativePath.startsWith("..") && !import_node_path.default.isAbsolute(relativePath);
|
|
282
|
+
var anchorToCwd = (directory, body, cwd) => {
|
|
283
|
+
const relativePath = (0, import_slash.default)(import_node_path.default.relative(cwd, import_node_path.default.join(directory, body)));
|
|
284
|
+
return isInsideCwd(relativePath) ? relativePath : void 0;
|
|
285
|
+
};
|
|
286
|
+
var createNameComparer = () => {
|
|
287
|
+
const nameMatchers = /* @__PURE__ */ new Map();
|
|
288
|
+
const matchesName = (pattern, name) => {
|
|
289
|
+
const namePath = unescapeGitignorePattern(name);
|
|
290
|
+
if (!(0, import_ignore.isPathValid)(namePath)) {
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
const normalizedPattern = normalizeGitignorePatternForIgnore(pattern);
|
|
294
|
+
let nameMatcher = nameMatchers.get(normalizedPattern);
|
|
295
|
+
if (!nameMatcher) {
|
|
296
|
+
nameMatcher = (0, import_ignore.default)().add([toStandaloneRule(normalizedPattern)]);
|
|
297
|
+
nameMatchers.set(normalizedPattern, nameMatcher);
|
|
298
|
+
}
|
|
299
|
+
return nameMatcher.ignores(namePath);
|
|
300
|
+
};
|
|
301
|
+
return (pattern, name) => {
|
|
302
|
+
if (hasGitignoreWildcards(pattern) && hasGitignoreWildcards(name)) {
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
return hasGitignoreWildcards(name) ? matchesName(name, pattern) : matchesName(pattern, name);
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
var getNegationFinalSegments = (rules) => rules.filter((rule) => isNegativePattern(rule.pattern)).map((rule) => finalSegment(rule.pattern.slice(1))).filter(Boolean);
|
|
309
|
+
var negationsCouldRescue = (rules, names) => {
|
|
310
|
+
if (names.length === 0) {
|
|
311
|
+
return false;
|
|
274
312
|
}
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
313
|
+
const couldNameTheSamePath = createNameComparer();
|
|
314
|
+
return getNegationFinalSegments(rules).some((negation) => names.some((name) => couldNameTheSamePath(name, negation)));
|
|
315
|
+
};
|
|
316
|
+
var getRulePrune = ({ pattern, directory }, { cwd, matcher, hasNegations, canSkipAtAnyDepth, canMatchIgnoreFile, gitignoreOnlySearch }) => {
|
|
317
|
+
if (isNegativePattern(pattern)) {
|
|
318
|
+
return void 0;
|
|
319
|
+
}
|
|
320
|
+
const isDirectoryPattern = pattern.endsWith("/");
|
|
321
|
+
const clean = pattern.replace(/\/+$/u, "");
|
|
322
|
+
if (!clean) {
|
|
323
|
+
return void 0;
|
|
324
|
+
}
|
|
325
|
+
const body = clean.startsWith("**/") && !clean.slice(3).includes("/") ? clean.slice(3) : clean;
|
|
326
|
+
if (canMatchIgnoreFile(finalSegment(body))) {
|
|
327
|
+
return void 0;
|
|
328
|
+
}
|
|
329
|
+
const isGlob = hasGitignoreWildcards(body);
|
|
330
|
+
if (isGlob && MICROMATCH_ONLY_SYNTAX.test(body)) {
|
|
331
|
+
return void 0;
|
|
332
|
+
}
|
|
333
|
+
const toFastGlob = (value) => normalizeDirectoryPatternForFastGlob(`/${value}${isDirectoryPattern ? "/" : ""}`).replace(/^\//u, "");
|
|
334
|
+
if (!body.includes("/") && canSkipAtAnyDepth(body)) {
|
|
335
|
+
const relativeDirectory = (0, import_slash.default)(import_node_path.default.relative(cwd, directory));
|
|
336
|
+
const prefix = isInsideCwd(relativeDirectory) ? `${import_fast_glob.default.escapePath(relativeDirectory)}/` : "";
|
|
337
|
+
return { pattern: toFastGlob(`${prefix}**/${isGlob ? body : toLiteralPattern(body)}`), guardName: body };
|
|
338
|
+
}
|
|
339
|
+
const anchoredBody = body.replace(/^\//u, "");
|
|
340
|
+
const target = anchorToCwd(directory, isGlob ? anchoredBody : unescapeGitignorePattern(anchoredBody), cwd);
|
|
341
|
+
if (target === void 0) {
|
|
342
|
+
return void 0;
|
|
343
|
+
}
|
|
344
|
+
const guardName = finalSegment(anchoredBody);
|
|
345
|
+
if (isGlob) {
|
|
346
|
+
return hasNegations ? void 0 : { pattern: toFastGlob(target), guardName };
|
|
347
|
+
}
|
|
348
|
+
if (!matcher(import_node_path.default.resolve(cwd, target) + import_node_path.default.sep).ignored) {
|
|
349
|
+
return void 0;
|
|
350
|
+
}
|
|
351
|
+
const needsGuard = !gitignoreOnlySearch || target.includes("/");
|
|
352
|
+
return {
|
|
353
|
+
pattern: toFastGlob(import_fast_glob.default.escapePath(target)),
|
|
354
|
+
guardName: needsGuard ? guardName : void 0
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
var buildPrunePatternsAndGuards = (rules, matcher, cwd, { gitignoreOnlySearch = false, searchesForGitignoreFiles = false } = {}) => {
|
|
358
|
+
if (!matcher || !cwd || !rules || rules.length === 0) {
|
|
359
|
+
return { patterns: [], guardNames: [] };
|
|
360
|
+
}
|
|
361
|
+
const negationNames = getNegationFinalSegments(rules);
|
|
362
|
+
const couldNameTheSamePath = createNameComparer();
|
|
363
|
+
const context = {
|
|
364
|
+
cwd,
|
|
365
|
+
matcher,
|
|
366
|
+
hasNegations: negationNames.length > 0,
|
|
367
|
+
canSkipAtAnyDepth: (pattern) => !negationNames.some((name) => couldNameTheSamePath(pattern, name)),
|
|
368
|
+
canMatchIgnoreFile: (pattern) => searchesForGitignoreFiles && couldNameTheSamePath(pattern, ".gitignore"),
|
|
369
|
+
gitignoreOnlySearch
|
|
370
|
+
};
|
|
371
|
+
const patterns = [];
|
|
372
|
+
const guardNames = [];
|
|
373
|
+
for (const rule of rules) {
|
|
374
|
+
const prune = getRulePrune(rule, context);
|
|
375
|
+
if (!prune) {
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
patterns.push(prune.pattern);
|
|
379
|
+
if (prune.guardName !== void 0) {
|
|
380
|
+
guardNames.push(prune.guardName);
|
|
281
381
|
}
|
|
282
|
-
result.push(normalizeDirectoryPatternForFastGlob2(pattern).replace(/^\//, ""));
|
|
283
382
|
}
|
|
284
|
-
return
|
|
383
|
+
return { patterns, guardNames };
|
|
285
384
|
};
|
|
385
|
+
var convertPatternsForFastGlob = (rules, matcher, cwd) => buildPrunePatternsAndGuards(rules, matcher, cwd).patterns;
|
|
286
386
|
|
|
287
|
-
// packages/@cjser/globby.tmp-26-
|
|
387
|
+
// packages/@cjser/globby.tmp-26-1786379054379/ignore.js
|
|
288
388
|
var defaultIgnoredDirectories = [
|
|
289
389
|
"**/node_modules",
|
|
290
390
|
"**/flow-typed",
|
|
@@ -358,17 +458,33 @@ var globIgnoreFiles = (globFunction, patterns, normalizedOptions) => globFunctio
|
|
|
358
458
|
...ignoreFilesGlobOptions
|
|
359
459
|
// Must be last to ensure absolute/dot flags stick
|
|
360
460
|
});
|
|
361
|
-
var
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
461
|
+
var normalizeIgnoreFileLine = (line) => {
|
|
462
|
+
line = line.replace(/^\uFEFF/u, "");
|
|
463
|
+
let whitespaceStart = line.length;
|
|
464
|
+
while (whitespaceStart > 0 && /\s/u.test(line[whitespaceStart - 1])) {
|
|
465
|
+
whitespaceStart--;
|
|
466
|
+
}
|
|
467
|
+
if (whitespaceStart === line.length) {
|
|
468
|
+
return line;
|
|
469
|
+
}
|
|
470
|
+
let backslashCount = 0;
|
|
471
|
+
for (let index = whitespaceStart - 1; index >= 0 && line[index] === "\\"; index--) {
|
|
472
|
+
backslashCount++;
|
|
473
|
+
}
|
|
474
|
+
return backslashCount % 2 === 1 ? line.slice(0, whitespaceStart) + " " : line.slice(0, whitespaceStart);
|
|
475
|
+
};
|
|
476
|
+
var readIgnoreFileLines = (content) => content.split(/\r?\n/).map((line) => normalizeIgnoreFileLine(line)).filter((line) => line && !line.startsWith("#"));
|
|
477
|
+
var getIgnoreRules = (files) => files.flatMap((file) => {
|
|
478
|
+
const directory = import_node_path2.default.dirname(file.filePath);
|
|
479
|
+
return readIgnoreFileLines(file.content).map((pattern) => ({ pattern, directory }));
|
|
480
|
+
});
|
|
366
481
|
var buildIgnoreResult = (files, normalizedOptions, gitRoot) => {
|
|
367
482
|
const baseDir = gitRoot || normalizedOptions.cwd;
|
|
368
483
|
const patterns = getPatternsFromIgnoreFiles(files, baseDir);
|
|
369
484
|
const matcher = createIgnoreMatcher(patterns, normalizedOptions.cwd, baseDir);
|
|
370
485
|
return {
|
|
371
486
|
patterns,
|
|
487
|
+
rules: getIgnoreRules(files),
|
|
372
488
|
matcher,
|
|
373
489
|
predicate: (fileOrDirectory) => matcher(fileOrDirectory).ignored,
|
|
374
490
|
usingGitRoot: Boolean(gitRoot && gitRoot !== normalizedOptions.cwd)
|
|
@@ -393,8 +509,8 @@ var applyBaseToPattern = (pattern, base) => {
|
|
|
393
509
|
return isNegative ? "!" + result : result;
|
|
394
510
|
};
|
|
395
511
|
var parseIgnoreFile = (file, cwd) => {
|
|
396
|
-
const base = (0,
|
|
397
|
-
return file.content
|
|
512
|
+
const base = (0, import_slash2.default)(import_node_path2.default.relative(cwd, import_node_path2.default.dirname(file.filePath)));
|
|
513
|
+
return readIgnoreFileLines(file.content).map((pattern) => applyBaseToPattern(pattern, base));
|
|
398
514
|
};
|
|
399
515
|
var toRelativePath = (fileOrDirectory, cwd) => {
|
|
400
516
|
if (import_node_path2.default.isAbsolute(fileOrDirectory)) {
|
|
@@ -414,7 +530,7 @@ var toRelativePath = (fileOrDirectory, cwd) => {
|
|
|
414
530
|
};
|
|
415
531
|
var notIgnored = { ignored: false, unignored: false };
|
|
416
532
|
var createIgnoreMatcher = (patterns, cwd, baseDir) => {
|
|
417
|
-
const ignores = (0,
|
|
533
|
+
const ignores = (0, import_ignore2.default)().add(patterns);
|
|
418
534
|
const resolvedCwd = import_node_path2.default.normalize(import_node_path2.default.resolve(cwd));
|
|
419
535
|
const resolvedBaseDir = import_node_path2.default.normalize(import_node_path2.default.resolve(baseDir));
|
|
420
536
|
return (fileOrDirectory) => {
|
|
@@ -434,7 +550,7 @@ var createIgnoreMatcher = (patterns, cwd, baseDir) => {
|
|
|
434
550
|
if (hasTrailingSeparator && !relativePath.endsWith(import_node_path2.default.sep)) {
|
|
435
551
|
relativePath += import_node_path2.default.sep;
|
|
436
552
|
}
|
|
437
|
-
return ignores.test((0,
|
|
553
|
+
return ignores.test((0, import_slash2.default)(relativePath));
|
|
438
554
|
};
|
|
439
555
|
};
|
|
440
556
|
var normalizeOptions = (options = {}) => {
|
|
@@ -560,7 +676,7 @@ var normalizeGitConfigConditionPattern = (pattern, configFilePath) => {
|
|
|
560
676
|
if (pattern.endsWith("/")) {
|
|
561
677
|
pattern += "**";
|
|
562
678
|
}
|
|
563
|
-
return (0,
|
|
679
|
+
return (0, import_slash2.default)(pattern);
|
|
564
680
|
};
|
|
565
681
|
var gitConfigGlobToRegex = (pattern, flags) => {
|
|
566
682
|
let regex = "";
|
|
@@ -618,7 +734,7 @@ var matchesIncludeIfCondition = (condition, gitDirectory, configFilePath) => {
|
|
|
618
734
|
const pattern = normalizeGitConfigConditionPattern(rawPattern.trim(), configFilePath);
|
|
619
735
|
const isCaseInsensitive = keyword.toLowerCase() === "gitdir/i";
|
|
620
736
|
const regularExpression = gitConfigGlobToRegex(pattern, isCaseInsensitive ? "i" : void 0);
|
|
621
|
-
const normalizedGitDirectory = (0,
|
|
737
|
+
const normalizedGitDirectory = (0, import_slash2.default)(import_node_path2.default.resolve(gitDirectory));
|
|
622
738
|
return regularExpression.test(normalizedGitDirectory);
|
|
623
739
|
};
|
|
624
740
|
var shouldIncludeConfigSection = (section, gitDirectory, configFilePath) => {
|
|
@@ -830,23 +946,103 @@ var buildGlobalMatcher = (globalIgnoreFile, cwd, rootDirectory = cwd) => {
|
|
|
830
946
|
const patterns = parseIgnoreFile(globalIgnoreFile, import_node_path2.default.dirname(globalIgnoreFile.filePath));
|
|
831
947
|
return createIgnoreMatcher(patterns, cwd, rootDirectory);
|
|
832
948
|
};
|
|
949
|
+
var getKnownIgnoreFilePaths = (patterns, normalizedOptions, gitRoot) => {
|
|
950
|
+
const searchPatterns = [patterns].flat();
|
|
951
|
+
const isGitignoreSearch = searchPatterns.includes(GITIGNORE_FILES_PATTERN);
|
|
952
|
+
if (!isGitignoreSearch) {
|
|
953
|
+
return [];
|
|
954
|
+
}
|
|
955
|
+
return gitRoot ? getParentGitignorePaths(gitRoot, normalizedOptions.cwd) : [import_node_path2.default.join(normalizedOptions.cwd, ".gitignore")];
|
|
956
|
+
};
|
|
957
|
+
var getKnownIgnoreFileSearchOptions = (patterns, normalizedOptions) => ({
|
|
958
|
+
...normalizedOptions,
|
|
959
|
+
ignore: [
|
|
960
|
+
...normalizedOptions.ignore,
|
|
961
|
+
// Keep negative search patterns active when the known candidates are matched independently.
|
|
962
|
+
...[patterns].flat().filter((pattern) => isNegativePattern(pattern)).map((pattern) => pattern.slice(1))
|
|
963
|
+
]
|
|
964
|
+
});
|
|
965
|
+
var getKnownIgnoreFilePattern = (filePath, cwd) => {
|
|
966
|
+
const pattern = (0, import_is_path_inside2.default)(filePath, cwd) ? import_node_path2.default.relative(cwd, filePath) : filePath;
|
|
967
|
+
return import_fast_glob2.default.convertPathToPattern(pattern);
|
|
968
|
+
};
|
|
969
|
+
var getMatchingKnownIgnoreFilePaths = (knownPaths, matchingPaths) => {
|
|
970
|
+
const matchingPathSet = new Set(matchingPaths.map((filePath) => import_node_path2.default.resolve(filePath)));
|
|
971
|
+
return knownPaths.filter((filePath) => matchingPathSet.has(import_node_path2.default.resolve(filePath)));
|
|
972
|
+
};
|
|
973
|
+
var globKnownIgnoreFilePaths = (globFunction, knownPaths, patterns, normalizedOptions) => {
|
|
974
|
+
if (knownPaths.length === 0) {
|
|
975
|
+
return [];
|
|
976
|
+
}
|
|
977
|
+
return globIgnoreFiles(
|
|
978
|
+
globFunction,
|
|
979
|
+
knownPaths.map((filePath) => getKnownIgnoreFilePattern(filePath, normalizedOptions.cwd)),
|
|
980
|
+
getKnownIgnoreFileSearchOptions(patterns, normalizedOptions)
|
|
981
|
+
);
|
|
982
|
+
};
|
|
983
|
+
var filterKnownIgnoreFilePathsAsync = async (knownPaths, patterns, normalizedOptions) => {
|
|
984
|
+
const matchingPaths = await globKnownIgnoreFilePaths(import_fast_glob2.default, knownPaths, patterns, normalizedOptions);
|
|
985
|
+
return getMatchingKnownIgnoreFilePaths(knownPaths, matchingPaths);
|
|
986
|
+
};
|
|
987
|
+
var filterKnownIgnoreFilePathsSync = (knownPaths, patterns, normalizedOptions) => {
|
|
988
|
+
const matchingPaths = globKnownIgnoreFilePaths(import_fast_glob2.default.sync, knownPaths, patterns, normalizedOptions);
|
|
989
|
+
return getMatchingKnownIgnoreFilePaths(knownPaths, matchingPaths);
|
|
990
|
+
};
|
|
991
|
+
var getIgnoreFileSearchPrune = (searchPatterns, files, normalizedOptions, gitRoot) => {
|
|
992
|
+
if (files.length === 0) {
|
|
993
|
+
return { patterns: [], guardNames: [] };
|
|
994
|
+
}
|
|
995
|
+
const { cwd } = normalizedOptions;
|
|
996
|
+
const baseDir = gitRoot || cwd;
|
|
997
|
+
const ignorePatterns = getPatternsFromIgnoreFiles(files, baseDir);
|
|
998
|
+
const matcher = createIgnoreMatcher(ignorePatterns, cwd, baseDir);
|
|
999
|
+
const searchPatternsArray = [searchPatterns].flat();
|
|
1000
|
+
const gitignoreOnlySearch = searchPatternsArray.every((pattern) => pattern === GITIGNORE_FILES_PATTERN);
|
|
1001
|
+
const searchesForGitignoreFiles = searchPatternsArray.includes(GITIGNORE_FILES_PATTERN);
|
|
1002
|
+
return buildPrunePatternsAndGuards(getIgnoreRules(files), matcher, cwd, { gitignoreOnlySearch, searchesForGitignoreFiles });
|
|
1003
|
+
};
|
|
1004
|
+
var withPrunedSearch = (normalizedOptions, prunePatterns) => prunePatterns.length === 0 ? normalizedOptions : { ...normalizedOptions, ignore: [...normalizedOptions.ignore, ...prunePatterns] };
|
|
1005
|
+
var getUnreadPaths = (childPaths, knownPaths) => {
|
|
1006
|
+
const alreadyRead = new Set(knownPaths.map((filePath) => import_node_path2.default.resolve(filePath)));
|
|
1007
|
+
return dedupePaths(childPaths).filter((filePath) => !alreadyRead.has(import_node_path2.default.resolve(filePath)));
|
|
1008
|
+
};
|
|
833
1009
|
var collectIgnoreFileArtifactsAsync = async (patterns, options, includeParentIgnoreFiles) => {
|
|
834
1010
|
const normalizedOptions = normalizeOptions(options);
|
|
835
|
-
const childPaths = await globIgnoreFiles(import_fast_glob2.default, patterns, normalizedOptions);
|
|
836
|
-
const gitRoot = includeParentIgnoreFiles ? await findGitRoot(normalizedOptions.cwd, normalizedOptions.fs) : void 0;
|
|
837
|
-
const allPaths = combineIgnoreFilePaths(gitRoot, normalizedOptions, childPaths);
|
|
838
1011
|
const readFileMethod = getReadFileMethod(normalizedOptions.fs);
|
|
839
|
-
const
|
|
840
|
-
|
|
1012
|
+
const gitRoot = includeParentIgnoreFiles ? await findGitRoot(normalizedOptions.cwd, normalizedOptions.fs) : void 0;
|
|
1013
|
+
const knownPaths = await filterKnownIgnoreFilePathsAsync(
|
|
1014
|
+
getKnownIgnoreFilePaths(patterns, normalizedOptions, gitRoot),
|
|
1015
|
+
patterns,
|
|
1016
|
+
normalizedOptions
|
|
1017
|
+
);
|
|
1018
|
+
const knownFiles = await readIgnoreFilesSafely(knownPaths, readFileMethod, normalizedOptions.suppressErrors);
|
|
1019
|
+
const { patterns: prunePatterns, guardNames } = getIgnoreFileSearchPrune(patterns, knownFiles, normalizedOptions, gitRoot);
|
|
1020
|
+
const childPaths = await globIgnoreFiles(import_fast_glob2.default, patterns, withPrunedSearch(normalizedOptions, prunePatterns));
|
|
1021
|
+
let childFiles = await readIgnoreFilesSafely(getUnreadPaths(childPaths, knownPaths), readFileMethod, normalizedOptions.suppressErrors);
|
|
1022
|
+
if (negationsCouldRescue(getIgnoreRules(childFiles), guardNames)) {
|
|
1023
|
+
const allPaths = await globIgnoreFiles(import_fast_glob2.default, patterns, normalizedOptions);
|
|
1024
|
+
childFiles = await readIgnoreFilesSafely(getUnreadPaths(allPaths, knownPaths), readFileMethod, normalizedOptions.suppressErrors);
|
|
1025
|
+
}
|
|
1026
|
+
return { files: [...knownFiles, ...childFiles], normalizedOptions, gitRoot };
|
|
841
1027
|
};
|
|
842
1028
|
var collectIgnoreFileArtifactsSync = (patterns, options, includeParentIgnoreFiles) => {
|
|
843
1029
|
const normalizedOptions = normalizeOptions(options);
|
|
844
|
-
const childPaths = globIgnoreFiles(import_fast_glob2.default.sync, patterns, normalizedOptions);
|
|
845
|
-
const gitRoot = includeParentIgnoreFiles ? findGitRootSync(normalizedOptions.cwd, normalizedOptions.fs) : void 0;
|
|
846
|
-
const allPaths = combineIgnoreFilePaths(gitRoot, normalizedOptions, childPaths);
|
|
847
1030
|
const readFileSyncMethod = getReadFileSyncMethod(normalizedOptions.fs);
|
|
848
|
-
const
|
|
849
|
-
|
|
1031
|
+
const gitRoot = includeParentIgnoreFiles ? findGitRootSync(normalizedOptions.cwd, normalizedOptions.fs) : void 0;
|
|
1032
|
+
const knownPaths = filterKnownIgnoreFilePathsSync(
|
|
1033
|
+
getKnownIgnoreFilePaths(patterns, normalizedOptions, gitRoot),
|
|
1034
|
+
patterns,
|
|
1035
|
+
normalizedOptions
|
|
1036
|
+
);
|
|
1037
|
+
const knownFiles = readIgnoreFilesSafelySync(knownPaths, readFileSyncMethod, normalizedOptions.suppressErrors);
|
|
1038
|
+
const { patterns: prunePatterns, guardNames } = getIgnoreFileSearchPrune(patterns, knownFiles, normalizedOptions, gitRoot);
|
|
1039
|
+
const childPaths = globIgnoreFiles(import_fast_glob2.default.sync, patterns, withPrunedSearch(normalizedOptions, prunePatterns));
|
|
1040
|
+
let childFiles = readIgnoreFilesSafelySync(getUnreadPaths(childPaths, knownPaths), readFileSyncMethod, normalizedOptions.suppressErrors);
|
|
1041
|
+
if (negationsCouldRescue(getIgnoreRules(childFiles), guardNames)) {
|
|
1042
|
+
const allPaths = globIgnoreFiles(import_fast_glob2.default.sync, patterns, normalizedOptions);
|
|
1043
|
+
childFiles = readIgnoreFilesSafelySync(getUnreadPaths(allPaths, knownPaths), readFileSyncMethod, normalizedOptions.suppressErrors);
|
|
1044
|
+
}
|
|
1045
|
+
return { files: [...knownFiles, ...childFiles], normalizedOptions, gitRoot };
|
|
850
1046
|
};
|
|
851
1047
|
var isIgnoredByIgnoreFiles = async (patterns, options) => {
|
|
852
1048
|
const { files, normalizedOptions, gitRoot } = await collectIgnoreFileArtifactsAsync(patterns, options, false);
|
|
@@ -876,7 +1072,7 @@ var getIgnorePatternsAndPredicateSync = (patterns, options, includeParentIgnoreF
|
|
|
876
1072
|
var isGitIgnored = (options) => isIgnoredByIgnoreFiles(GITIGNORE_FILES_PATTERN, options);
|
|
877
1073
|
var isGitIgnoredSync = (options) => isIgnoredByIgnoreFilesSync(GITIGNORE_FILES_PATTERN, options);
|
|
878
1074
|
|
|
879
|
-
// packages/@cjser/globby.tmp-26-
|
|
1075
|
+
// packages/@cjser/globby.tmp-26-1786379054379/index.js
|
|
880
1076
|
var assertPatternsInput = (patterns) => {
|
|
881
1077
|
if (patterns.some((pattern) => typeof pattern !== "string")) {
|
|
882
1078
|
throw new TypeError("Patterns must be a string or an array of strings");
|
|
@@ -1026,14 +1222,12 @@ var combinePredicate = (matcher, globalMatcher) => {
|
|
|
1026
1222
|
return isPathIgnored(matcher, globalMatcher, file);
|
|
1027
1223
|
};
|
|
1028
1224
|
};
|
|
1029
|
-
var buildIgnoreFilterResult = (options, cwd, {
|
|
1225
|
+
var buildIgnoreFilterResult = ({ options, cwd, ignoreResult: { rules, matcher }, globalMatcher, createFilter }) => {
|
|
1030
1226
|
const finalPredicate = combinePredicate(matcher, globalMatcher);
|
|
1031
|
-
const
|
|
1227
|
+
const pruneIgnorePatterns = convertPatternsForFastGlob(rules, matcher, cwd);
|
|
1032
1228
|
return {
|
|
1033
|
-
options
|
|
1034
|
-
|
|
1035
|
-
ignore: [...options.ignore, ...patternsForFastGlob]
|
|
1036
|
-
},
|
|
1229
|
+
options,
|
|
1230
|
+
pruneIgnorePatterns,
|
|
1037
1231
|
filter: createFilter(finalPredicate, cwd, options.fs)
|
|
1038
1232
|
};
|
|
1039
1233
|
};
|
|
@@ -1044,14 +1238,21 @@ var applyIgnoreFilesAndGetFilter = async (options) => {
|
|
|
1044
1238
|
if (ignoreFilesPatterns.length === 0 && !globalIgnoreFile) {
|
|
1045
1239
|
return {
|
|
1046
1240
|
options,
|
|
1241
|
+
pruneIgnorePatterns: [],
|
|
1047
1242
|
filter: createFilterFunctionAsync(false, cwd, options.fs)
|
|
1048
1243
|
};
|
|
1049
1244
|
}
|
|
1050
1245
|
const includeParentIgnoreFiles = options.gitignore === true;
|
|
1051
|
-
const ignoreResult = ignoreFilesPatterns.length > 0 ? await getIgnorePatternsAndPredicate(ignoreFilesPatterns, options, includeParentIgnoreFiles) : {
|
|
1246
|
+
const ignoreResult = ignoreFilesPatterns.length > 0 ? await getIgnorePatternsAndPredicate(ignoreFilesPatterns, options, includeParentIgnoreFiles) : { rules: [], matcher: false };
|
|
1052
1247
|
const globalGitRoot = globalIgnoreFile ? await findGitRoot(cwd, options.fs) : void 0;
|
|
1053
1248
|
const globalMatcher = globalIgnoreFile ? buildGlobalMatcher(globalIgnoreFile, cwd, globalGitRoot ?? cwd) : void 0;
|
|
1054
|
-
return buildIgnoreFilterResult(
|
|
1249
|
+
return buildIgnoreFilterResult({
|
|
1250
|
+
options,
|
|
1251
|
+
cwd,
|
|
1252
|
+
ignoreResult,
|
|
1253
|
+
globalMatcher,
|
|
1254
|
+
createFilter: createFilterFunctionAsync
|
|
1255
|
+
});
|
|
1055
1256
|
};
|
|
1056
1257
|
var applyIgnoreFilesAndGetFilterSync = (options) => {
|
|
1057
1258
|
const cwd = options.cwd ?? import_node_process2.default.cwd();
|
|
@@ -1060,14 +1261,21 @@ var applyIgnoreFilesAndGetFilterSync = (options) => {
|
|
|
1060
1261
|
if (ignoreFilesPatterns.length === 0 && !globalIgnoreFile) {
|
|
1061
1262
|
return {
|
|
1062
1263
|
options,
|
|
1264
|
+
pruneIgnorePatterns: [],
|
|
1063
1265
|
filter: createFilterFunction(false, cwd, options.fs)
|
|
1064
1266
|
};
|
|
1065
1267
|
}
|
|
1066
1268
|
const includeParentIgnoreFiles = options.gitignore === true;
|
|
1067
|
-
const ignoreResult = ignoreFilesPatterns.length > 0 ? getIgnorePatternsAndPredicateSync(ignoreFilesPatterns, options, includeParentIgnoreFiles) : {
|
|
1269
|
+
const ignoreResult = ignoreFilesPatterns.length > 0 ? getIgnorePatternsAndPredicateSync(ignoreFilesPatterns, options, includeParentIgnoreFiles) : { rules: [], matcher: false };
|
|
1068
1270
|
const globalGitRoot = globalIgnoreFile ? findGitRootSync(cwd, options.fs) : void 0;
|
|
1069
1271
|
const globalMatcher = globalIgnoreFile ? buildGlobalMatcher(globalIgnoreFile, cwd, globalGitRoot ?? cwd) : void 0;
|
|
1070
|
-
return buildIgnoreFilterResult(
|
|
1272
|
+
return buildIgnoreFilterResult({
|
|
1273
|
+
options,
|
|
1274
|
+
cwd,
|
|
1275
|
+
ignoreResult,
|
|
1276
|
+
globalMatcher,
|
|
1277
|
+
createFilter: createFilterFunction
|
|
1278
|
+
});
|
|
1071
1279
|
};
|
|
1072
1280
|
var assertGlobalGitignoreSyncSupport = (options) => {
|
|
1073
1281
|
if (options.globalGitignore && options.fs && !options.fs.statSync) {
|
|
@@ -1250,21 +1458,28 @@ var applyParentDirectoryIgnoreAdjustments = (tasks) => tasks.map((task) => ({
|
|
|
1250
1458
|
ignore: adjustIgnorePatternsForParentDirectories(task.patterns, task.options.ignore)
|
|
1251
1459
|
}
|
|
1252
1460
|
}));
|
|
1461
|
+
var appendPruneIgnorePatterns = (tasks, pruneIgnorePatterns) => pruneIgnorePatterns.length === 0 ? tasks : tasks.map((task) => ({
|
|
1462
|
+
patterns: task.patterns,
|
|
1463
|
+
options: {
|
|
1464
|
+
...task.options,
|
|
1465
|
+
ignore: [...task.options.ignore, ...pruneIgnorePatterns]
|
|
1466
|
+
}
|
|
1467
|
+
}));
|
|
1253
1468
|
var normalizeExpandDirectoriesOption = (options, cwd) => ({
|
|
1254
1469
|
...cwd ? { cwd } : {},
|
|
1255
1470
|
...Array.isArray(options) ? { files: options } : options
|
|
1256
1471
|
});
|
|
1257
|
-
var generateTasks = async (patterns, options) => {
|
|
1472
|
+
var generateTasks = async (patterns, options, pruneIgnorePatterns = []) => {
|
|
1258
1473
|
const globTasks = convertNegativePatterns(patterns, options);
|
|
1259
1474
|
const { cwd, expandDirectories, fs: fsImplementation } = options;
|
|
1260
1475
|
if (!expandDirectories) {
|
|
1261
|
-
return applyParentDirectoryIgnoreAdjustments(globTasks);
|
|
1476
|
+
return appendPruneIgnorePatterns(applyParentDirectoryIgnoreAdjustments(globTasks), pruneIgnorePatterns);
|
|
1262
1477
|
}
|
|
1263
1478
|
const directoryToGlobOptions = {
|
|
1264
1479
|
...normalizeExpandDirectoriesOption(expandDirectories, cwd),
|
|
1265
1480
|
fs: fsImplementation
|
|
1266
1481
|
};
|
|
1267
|
-
|
|
1482
|
+
const tasks = await Promise.all(globTasks.map(async (task) => {
|
|
1268
1483
|
let { patterns: patterns2, options: options2 } = task;
|
|
1269
1484
|
[
|
|
1270
1485
|
patterns2,
|
|
@@ -1276,36 +1491,38 @@ var generateTasks = async (patterns, options) => {
|
|
|
1276
1491
|
options2.ignore = adjustIgnorePatternsForParentDirectories(patterns2, options2.ignore);
|
|
1277
1492
|
return { patterns: patterns2, options: options2 };
|
|
1278
1493
|
}));
|
|
1494
|
+
return appendPruneIgnorePatterns(tasks, pruneIgnorePatterns);
|
|
1279
1495
|
};
|
|
1280
|
-
var generateTasksSync = (patterns, options) => {
|
|
1496
|
+
var generateTasksSync = (patterns, options, pruneIgnorePatterns = []) => {
|
|
1281
1497
|
const globTasks = convertNegativePatterns(patterns, options);
|
|
1282
1498
|
const { cwd, expandDirectories, fs: fsImplementation } = options;
|
|
1283
1499
|
if (!expandDirectories) {
|
|
1284
|
-
return applyParentDirectoryIgnoreAdjustments(globTasks);
|
|
1500
|
+
return appendPruneIgnorePatterns(applyParentDirectoryIgnoreAdjustments(globTasks), pruneIgnorePatterns);
|
|
1285
1501
|
}
|
|
1286
1502
|
const directoryToGlobSyncOptions = {
|
|
1287
1503
|
...normalizeExpandDirectoriesOption(expandDirectories, cwd),
|
|
1288
1504
|
fs: fsImplementation
|
|
1289
1505
|
};
|
|
1290
|
-
|
|
1506
|
+
const tasks = globTasks.map((task) => {
|
|
1291
1507
|
let { patterns: patterns2, options: options2 } = task;
|
|
1292
1508
|
patterns2 = directoryToGlobSync(patterns2, directoryToGlobSyncOptions);
|
|
1293
1509
|
options2.ignore = directoryToGlobSync(options2.ignore, { cwd, fs: fsImplementation });
|
|
1294
1510
|
options2.ignore = adjustIgnorePatternsForParentDirectories(patterns2, options2.ignore);
|
|
1295
1511
|
return { patterns: patterns2, options: options2 };
|
|
1296
1512
|
});
|
|
1513
|
+
return appendPruneIgnorePatterns(tasks, pruneIgnorePatterns);
|
|
1297
1514
|
};
|
|
1298
1515
|
var globby = normalizeArguments(async (patterns, options) => {
|
|
1299
1516
|
assertGlobalGitignoreAsyncSupport(options);
|
|
1300
|
-
const { options: modifiedOptions, filter } = await applyIgnoreFilesAndGetFilter(options);
|
|
1301
|
-
const tasks = await generateTasks(patterns, modifiedOptions);
|
|
1517
|
+
const { options: modifiedOptions, pruneIgnorePatterns, filter } = await applyIgnoreFilesAndGetFilter(options);
|
|
1518
|
+
const tasks = await generateTasks(patterns, modifiedOptions, pruneIgnorePatterns);
|
|
1302
1519
|
const results = await Promise.all(tasks.map((task) => (0, import_fast_glob3.default)(task.patterns, task.options)));
|
|
1303
1520
|
return unionFastGlobResultsAsync(results, filter);
|
|
1304
1521
|
});
|
|
1305
1522
|
var globbySync = normalizeArgumentsSync((patterns, options) => {
|
|
1306
1523
|
assertGlobalGitignoreSyncSupport(options);
|
|
1307
|
-
const { options: modifiedOptions, filter } = applyIgnoreFilesAndGetFilterSync(options);
|
|
1308
|
-
const tasks = generateTasksSync(patterns, modifiedOptions);
|
|
1524
|
+
const { options: modifiedOptions, pruneIgnorePatterns, filter } = applyIgnoreFilesAndGetFilterSync(options);
|
|
1525
|
+
const tasks = generateTasksSync(patterns, modifiedOptions, pruneIgnorePatterns);
|
|
1309
1526
|
const results = tasks.map((task) => import_fast_glob3.default.sync(task.patterns, task.options));
|
|
1310
1527
|
return unionFastGlobResults(results, filter);
|
|
1311
1528
|
});
|
|
@@ -1313,8 +1530,8 @@ var globbyStream = normalizeArgumentsSync((patterns, options) => {
|
|
|
1313
1530
|
assertGlobalGitignoreAsyncSupport(options);
|
|
1314
1531
|
const seen = /* @__PURE__ */ new Set();
|
|
1315
1532
|
const stream = import_node_stream.Readable.from((async function* () {
|
|
1316
|
-
const { options: modifiedOptions, filter } = await applyIgnoreFilesAndGetFilter(options);
|
|
1317
|
-
const tasks = await generateTasks(patterns, modifiedOptions);
|
|
1533
|
+
const { options: modifiedOptions, pruneIgnorePatterns, filter } = await applyIgnoreFilesAndGetFilter(options);
|
|
1534
|
+
const tasks = await generateTasks(patterns, modifiedOptions, pruneIgnorePatterns);
|
|
1318
1535
|
if (tasks.length === 0) {
|
|
1319
1536
|
return;
|
|
1320
1537
|
}
|