fast-glob-fast 4.0.0

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.
Files changed (60) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +817 -0
  3. package/out/index.d.ts +49 -0
  4. package/out/index.js +99 -0
  5. package/out/managers/tasks.d.ts +22 -0
  6. package/out/managers/tasks.js +114 -0
  7. package/out/providers/async.d.ts +11 -0
  8. package/out/providers/async.js +24 -0
  9. package/out/providers/filters/deep.d.ts +7 -0
  10. package/out/providers/filters/deep.js +64 -0
  11. package/out/providers/filters/entry.d.ts +8 -0
  12. package/out/providers/filters/entry.js +88 -0
  13. package/out/providers/filters/error.d.ts +7 -0
  14. package/out/providers/filters/error.js +16 -0
  15. package/out/providers/index.d.ts +3 -0
  16. package/out/providers/index.js +19 -0
  17. package/out/providers/matchers/matcher.d.ts +28 -0
  18. package/out/providers/matchers/matcher.js +48 -0
  19. package/out/providers/matchers/partial.d.ts +4 -0
  20. package/out/providers/matchers/partial.js +38 -0
  21. package/out/providers/provider.d.ts +19 -0
  22. package/out/providers/provider.js +55 -0
  23. package/out/providers/stream.d.ts +12 -0
  24. package/out/providers/stream.js +32 -0
  25. package/out/providers/sync.d.ts +11 -0
  26. package/out/providers/sync.js +24 -0
  27. package/out/providers/transformers/entry.d.ts +7 -0
  28. package/out/providers/transformers/entry.js +36 -0
  29. package/out/readers/async.d.ts +16 -0
  30. package/out/readers/async.js +34 -0
  31. package/out/readers/index.d.ts +3 -0
  32. package/out/readers/index.js +19 -0
  33. package/out/readers/reader.d.ts +13 -0
  34. package/out/readers/reader.js +36 -0
  35. package/out/readers/stream.d.ts +16 -0
  36. package/out/readers/stream.js +58 -0
  37. package/out/readers/sync.d.ts +15 -0
  38. package/out/readers/sync.js +41 -0
  39. package/out/settings.d.ts +162 -0
  40. package/out/settings.js +75 -0
  41. package/out/types/index.d.ts +34 -0
  42. package/out/types/index.js +2 -0
  43. package/out/utils/array.d.ts +2 -0
  44. package/out/utils/array.js +22 -0
  45. package/out/utils/errno.d.ts +2 -0
  46. package/out/utils/errno.js +6 -0
  47. package/out/utils/fs.d.ts +9 -0
  48. package/out/utils/fs.js +30 -0
  49. package/out/utils/index.d.ts +7 -0
  50. package/out/utils/index.js +10 -0
  51. package/out/utils/path.d.ts +10 -0
  52. package/out/utils/path.js +65 -0
  53. package/out/utils/pattern.d.ts +49 -0
  54. package/out/utils/pattern.js +210 -0
  55. package/out/utils/stream.d.ts +2 -0
  56. package/out/utils/stream.js +22 -0
  57. package/out/utils/string.d.ts +8 -0
  58. package/out/utils/string.js +22 -0
  59. package/package.json +89 -0
  60. package/scripts/postinstall-test.mjs +72 -0
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
4
+ const fs = require("node:fs");
5
+ exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
6
+ lstat: fs.lstat,
7
+ lstatSync: fs.lstatSync,
8
+ stat: fs.stat,
9
+ statSync: fs.statSync,
10
+ readdir: fs.readdir,
11
+ readdirSync: fs.readdirSync,
12
+ };
13
+ class Settings {
14
+ absolute;
15
+ baseNameMatch;
16
+ braceExpansion;
17
+ caseSensitiveMatch;
18
+ cwd;
19
+ deep;
20
+ dot;
21
+ extglob;
22
+ followSymbolicLinks;
23
+ fs;
24
+ globstar;
25
+ ignore;
26
+ markDirectories;
27
+ objectMode;
28
+ onlyDirectories;
29
+ onlyFiles;
30
+ stats;
31
+ suppressErrors;
32
+ throwErrorOnBrokenSymbolicLink;
33
+ unique;
34
+ signal;
35
+ // eslint-disable-next-line complexity
36
+ constructor(options = {}) {
37
+ if (options.deep !== undefined && options.deep < 0) {
38
+ throw new TypeError(`options.deep must be a non-negative number, received: ${options.deep}`);
39
+ }
40
+ this.absolute = options.absolute ?? false;
41
+ this.baseNameMatch = options.baseNameMatch ?? false;
42
+ this.braceExpansion = options.braceExpansion ?? true;
43
+ this.caseSensitiveMatch = options.caseSensitiveMatch ?? true;
44
+ this.cwd = options.cwd ?? process.cwd();
45
+ this.deep = options.deep ?? Number.POSITIVE_INFINITY;
46
+ this.dot = options.dot ?? false;
47
+ this.extglob = options.extglob ?? true;
48
+ this.followSymbolicLinks = options.followSymbolicLinks ?? true;
49
+ this.fs = this.#getFileSystemMethods(options.fs);
50
+ this.globstar = options.globstar ?? true;
51
+ this.ignore = options.ignore ?? [];
52
+ this.markDirectories = options.markDirectories ?? false;
53
+ this.objectMode = options.objectMode ?? false;
54
+ this.onlyDirectories = options.onlyDirectories ?? false;
55
+ this.onlyFiles = options.onlyFiles ?? true;
56
+ this.stats = options.stats ?? false;
57
+ this.suppressErrors = options.suppressErrors ?? false;
58
+ this.throwErrorOnBrokenSymbolicLink = options.throwErrorOnBrokenSymbolicLink ?? false;
59
+ this.unique = options.unique ?? true;
60
+ this.signal = options.signal;
61
+ if (this.onlyDirectories) {
62
+ this.onlyFiles = false;
63
+ }
64
+ if (this.stats) {
65
+ this.objectMode = true;
66
+ }
67
+ }
68
+ #getFileSystemMethods(methods = {}) {
69
+ return {
70
+ ...exports.DEFAULT_FILE_SYSTEM_ADAPTER,
71
+ ...methods,
72
+ };
73
+ }
74
+ }
75
+ exports.default = Settings;
@@ -0,0 +1,34 @@
1
+ import type * as fs from 'node:fs';
2
+ import type * as fsWalk from '@nodelib/fs.walk';
3
+ export type Dictionary<T = unknown> = Record<string, T>;
4
+ export type ErrnoException = NodeJS.ErrnoException;
5
+ export type FsDirent = fs.Dirent;
6
+ export type FsStats = fs.Stats;
7
+ export type Entry = fsWalk.Entry;
8
+ export type EntryItem = Entry | string;
9
+ export type Pattern = string;
10
+ export type PatternRe = RegExp;
11
+ export type PatternsGroup = Dictionary<Pattern[]>;
12
+ export type ReaderOptions = {
13
+ transform: (entry: Entry) => EntryItem;
14
+ deepFilter: DeepFilterFunction;
15
+ entryFilter: EntryFilterFunction;
16
+ errorFilter: ErrorFilterFunction;
17
+ fs: FileSystemAdapter;
18
+ stats: boolean;
19
+ } & fsWalk.Options;
20
+ export type ErrorFilterFunction = fsWalk.ErrorFilterFunction;
21
+ export type EntryFilterFunction = fsWalk.EntryFilterFunction;
22
+ export type DeepFilterFunction = fsWalk.DeepFilterFunction;
23
+ export type EntryTransformerFunction = (entry: Entry) => EntryItem;
24
+ export interface MicromatchOptions {
25
+ dot?: boolean;
26
+ matchBase?: boolean;
27
+ nobrace?: boolean;
28
+ nocase?: boolean;
29
+ noext?: boolean;
30
+ noglobstar?: boolean;
31
+ posix?: boolean;
32
+ strictSlashes?: boolean;
33
+ }
34
+ export type FileSystemAdapter = fsWalk.FileSystemAdapter;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export declare function flatFirstLevel<T>(items: T[][]): T[];
2
+ export declare function splitWhen<T>(items: T[], predicate: (item: T) => boolean): T[][];
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flatFirstLevel = flatFirstLevel;
4
+ exports.splitWhen = splitWhen;
5
+ function flatFirstLevel(items) {
6
+ // We do not use `Array.flat` because this is slower than current implementation for your case.
7
+ return [].concat(...items);
8
+ }
9
+ function splitWhen(items, predicate) {
10
+ const result = [[]];
11
+ let groupIndex = 0;
12
+ for (const item of items) {
13
+ if (predicate(item)) {
14
+ groupIndex++;
15
+ result[groupIndex] = [];
16
+ }
17
+ else {
18
+ result[groupIndex].push(item);
19
+ }
20
+ }
21
+ return result;
22
+ }
@@ -0,0 +1,2 @@
1
+ import type { ErrnoException } from '../types';
2
+ export declare function isEnoentCodeError(error: ErrnoException): boolean;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEnoentCodeError = isEnoentCodeError;
4
+ function isEnoentCodeError(error) {
5
+ return error.code === 'ENOENT';
6
+ }
@@ -0,0 +1,9 @@
1
+ import * as fs from 'node:fs';
2
+ import type { FsStats, FsDirent } from '../types';
3
+ declare const _kStats: unique symbol;
4
+ export declare class DirentFromStats extends fs.Dirent {
5
+ private readonly [_kStats];
6
+ constructor(name: string, stats: FsStats);
7
+ }
8
+ export declare function createDirentFromStats(name: string, stats: FsStats): FsDirent;
9
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DirentFromStats = void 0;
4
+ exports.createDirentFromStats = createDirentFromStats;
5
+ const fs = require("node:fs");
6
+ const _kStats = Symbol('stats');
7
+ // Adapting an internal class in Node.js to mimic the behavior of `fs.Dirent` when creating it manually from `fs.Stats`.
8
+ // https://github.com/nodejs/node/blob/a4cf6b204f0b160480153dc293ae748bf15225f9/lib/internal/fs/utils.js#L199C1-L213
9
+ class DirentFromStats extends fs.Dirent {
10
+ [_kStats];
11
+ constructor(name, stats) {
12
+ // @ts-expect-error The constructor has parameters, but they are not represented in types.
13
+ // https://github.com/nodejs/node/blob/a4cf6b204f0b160480153dc293ae748bf15225f9/lib/internal/fs/utils.js#L164
14
+ super(name, null);
15
+ this[_kStats] = stats;
16
+ }
17
+ }
18
+ exports.DirentFromStats = DirentFromStats;
19
+ for (const key of Reflect.ownKeys(fs.Dirent.prototype)) {
20
+ const name = key;
21
+ if (name === 'constructor') {
22
+ continue;
23
+ }
24
+ DirentFromStats.prototype[name] = function () {
25
+ return this[_kStats][name]();
26
+ };
27
+ }
28
+ function createDirentFromStats(name, stats) {
29
+ return new DirentFromStats(name, stats);
30
+ }
@@ -0,0 +1,7 @@
1
+ export * as array from './array';
2
+ export * as errno from './errno';
3
+ export * as fs from './fs';
4
+ export * as path from './path';
5
+ export * as pattern from './pattern';
6
+ export * as stream from './stream';
7
+ export * as string from './string';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.string = exports.stream = exports.pattern = exports.path = exports.fs = exports.errno = exports.array = void 0;
4
+ exports.array = require("./array");
5
+ exports.errno = require("./errno");
6
+ exports.fs = require("./fs");
7
+ exports.path = require("./path");
8
+ exports.pattern = require("./pattern");
9
+ exports.stream = require("./stream");
10
+ exports.string = require("./string");
@@ -0,0 +1,10 @@
1
+ import type { Pattern } from '../types';
2
+ export declare function makeAbsolute(cwd: string, filepath: string): string;
3
+ export declare function removeLeadingDotSegment(entry: string): string;
4
+ export declare function removeBackslashes(entry: string): string;
5
+ export declare const escape: typeof escapeWindowsPath;
6
+ export declare function escapeWindowsPath(pattern: Pattern): Pattern;
7
+ export declare function escapePosixPath(pattern: Pattern): Pattern;
8
+ export declare const convertPathToPattern: typeof convertWindowsPathToPattern;
9
+ export declare function convertWindowsPathToPattern(filepath: string): Pattern;
10
+ export declare function convertPosixPathToPattern(filepath: string): Pattern;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertPathToPattern = exports.escape = void 0;
4
+ exports.makeAbsolute = makeAbsolute;
5
+ exports.removeLeadingDotSegment = removeLeadingDotSegment;
6
+ exports.removeBackslashes = removeBackslashes;
7
+ exports.escapeWindowsPath = escapeWindowsPath;
8
+ exports.escapePosixPath = escapePosixPath;
9
+ exports.convertWindowsPathToPattern = convertWindowsPathToPattern;
10
+ exports.convertPosixPathToPattern = convertPosixPathToPattern;
11
+ const os = require("node:os");
12
+ const path = require("node:path");
13
+ const IS_WINDOWS_PLATFORM = os.platform() === 'win32';
14
+ const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
15
+ /**
16
+ * All non-escaped special characters.
17
+ * Posix: ()*?[]{|}, !+@ before (, ! at the beginning, \\ before non-special characters.
18
+ * Windows: (){}[], !+@ before (, ! at the beginning.
19
+ */
20
+ const POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(?<escape>\\?)(?<symbols>[()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
21
+ const WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(?<escape>\\?)(?<symbols>[()[\]{}]|^!|[!+@](?=\())/g;
22
+ /**
23
+ * The device path (\\.\ or \\?\).
24
+ * https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#dos-device-paths
25
+ */
26
+ const DOS_DEVICE_PATH_RE = /^\\\\(?<path>[.?])/;
27
+ /**
28
+ * All backslashes except those escaping special characters.
29
+ * Windows: !()+@{}
30
+ * https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
31
+ */
32
+ const WINDOWS_BACKSLASHES_RE = /\\(?![!()+@[\]{}])/g;
33
+ function makeAbsolute(cwd, filepath) {
34
+ return path.resolve(cwd, filepath);
35
+ }
36
+ function removeLeadingDotSegment(entry) {
37
+ // We do not use `startsWith` because this is 10x slower than current implementation for some cases.
38
+ // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
39
+ if (entry.charAt(0) === '.') {
40
+ const secondCharactery = entry.charAt(1);
41
+ if (secondCharactery === '/' || secondCharactery === '\\') {
42
+ return entry.slice(LEADING_DOT_SEGMENT_CHARACTERS_COUNT);
43
+ }
44
+ }
45
+ return entry;
46
+ }
47
+ function removeBackslashes(entry) {
48
+ return entry.replaceAll('\\', '');
49
+ }
50
+ exports.escape = IS_WINDOWS_PLATFORM ? escapeWindowsPath : escapePosixPath;
51
+ function escapeWindowsPath(pattern) {
52
+ return pattern.replaceAll(WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE, String.raw `\$2`);
53
+ }
54
+ function escapePosixPath(pattern) {
55
+ return pattern.replaceAll(POSIX_UNESCAPED_GLOB_SYMBOLS_RE, String.raw `\$2`);
56
+ }
57
+ exports.convertPathToPattern = IS_WINDOWS_PLATFORM ? convertWindowsPathToPattern : convertPosixPathToPattern;
58
+ function convertWindowsPathToPattern(filepath) {
59
+ return escapeWindowsPath(filepath)
60
+ .replace(DOS_DEVICE_PATH_RE, '//$1')
61
+ .replaceAll(WINDOWS_BACKSLASHES_RE, '/');
62
+ }
63
+ function convertPosixPathToPattern(filepath) {
64
+ return escapePosixPath(filepath);
65
+ }
@@ -0,0 +1,49 @@
1
+ import type { MicromatchOptions, Pattern, PatternRe } from '../types';
2
+ interface PatternTypeOptions {
3
+ braceExpansion?: boolean;
4
+ caseSensitiveMatch?: boolean;
5
+ extglob?: boolean;
6
+ }
7
+ export declare function isStaticPattern(pattern: Pattern, options?: PatternTypeOptions): boolean;
8
+ export declare function isDynamicPattern(pattern: Pattern, options?: PatternTypeOptions): boolean;
9
+ export declare function convertToPositivePattern(pattern: Pattern): Pattern;
10
+ export declare function convertToNegativePattern(pattern: Pattern): Pattern;
11
+ export declare function isNegativePattern(pattern: Pattern): boolean;
12
+ export declare function isPositivePattern(pattern: Pattern): boolean;
13
+ export declare function getNegativePatterns(patterns: Pattern[]): Pattern[];
14
+ export declare function getPositivePatterns(patterns: Pattern[]): Pattern[];
15
+ /**
16
+ * Returns patterns that can be applied inside the current directory.
17
+ *
18
+ * @example
19
+ * // ['./*', '*', 'a/*']
20
+ * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
21
+ */
22
+ export declare function getPatternsInsideCurrentDirectory(patterns: Pattern[]): Pattern[];
23
+ /**
24
+ * Returns patterns to be expanded relative to (outside) the current directory.
25
+ *
26
+ * @example
27
+ * // ['../*', './../*']
28
+ * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
29
+ */
30
+ export declare function getPatternsOutsideCurrentDirectory(patterns: Pattern[]): Pattern[];
31
+ export declare function isPatternRelatedToParentDirectory(pattern: Pattern): boolean;
32
+ export declare function getBaseDirectory(pattern: Pattern): string;
33
+ export declare function hasGlobStar(pattern: Pattern): boolean;
34
+ export declare function endsWithSlashGlobStar(pattern: Pattern): boolean;
35
+ export declare function isAffectDepthOfReadingPattern(pattern: Pattern): boolean;
36
+ export declare function expandPatternsWithBraceExpansion(patterns: Pattern[]): Pattern[];
37
+ export declare function expandBraceExpansion(pattern: Pattern): Pattern[];
38
+ export declare function getPatternParts(pattern: Pattern, options: MicromatchOptions): Pattern[];
39
+ export declare function makeRe(pattern: Pattern, options: MicromatchOptions): PatternRe;
40
+ export declare function convertPatternsToRe(patterns: Pattern[], options: MicromatchOptions): PatternRe[];
41
+ export declare function matchAny(entry: string, patternsRe: PatternRe[]): boolean;
42
+ /**
43
+ * This package only works with forward slashes as a path separator.
44
+ * Because of this, we cannot use the standard `path.normalize` method, because on Windows platform it will use of backslashes.
45
+ */
46
+ export declare function removeDuplicateSlashes(pattern: string): string;
47
+ export declare function partitionAbsoluteAndRelative(patterns: Pattern[]): [Pattern[], Pattern[]];
48
+ export declare function isAbsolute(pattern: string): boolean;
49
+ export {};
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isStaticPattern = isStaticPattern;
4
+ exports.isDynamicPattern = isDynamicPattern;
5
+ exports.convertToPositivePattern = convertToPositivePattern;
6
+ exports.convertToNegativePattern = convertToNegativePattern;
7
+ exports.isNegativePattern = isNegativePattern;
8
+ exports.isPositivePattern = isPositivePattern;
9
+ exports.getNegativePatterns = getNegativePatterns;
10
+ exports.getPositivePatterns = getPositivePatterns;
11
+ exports.getPatternsInsideCurrentDirectory = getPatternsInsideCurrentDirectory;
12
+ exports.getPatternsOutsideCurrentDirectory = getPatternsOutsideCurrentDirectory;
13
+ exports.isPatternRelatedToParentDirectory = isPatternRelatedToParentDirectory;
14
+ exports.getBaseDirectory = getBaseDirectory;
15
+ exports.hasGlobStar = hasGlobStar;
16
+ exports.endsWithSlashGlobStar = endsWithSlashGlobStar;
17
+ exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
18
+ exports.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;
19
+ exports.expandBraceExpansion = expandBraceExpansion;
20
+ exports.getPatternParts = getPatternParts;
21
+ exports.makeRe = makeRe;
22
+ exports.convertPatternsToRe = convertPatternsToRe;
23
+ exports.matchAny = matchAny;
24
+ exports.removeDuplicateSlashes = removeDuplicateSlashes;
25
+ exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
26
+ exports.isAbsolute = isAbsolute;
27
+ const path = require("node:path");
28
+ // https://stackoverflow.com/a/39415662
29
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
30
+ const globParent = require("glob-parent");
31
+ const micromatch = require("micromatch");
32
+ const GLOBSTAR = '**';
33
+ const ESCAPE_SYMBOL = '\\';
34
+ const COMMON_GLOB_SYMBOLS_RE = /[*?]|^!/;
35
+ const REGEX_CHARACTER_CLASS_SYMBOLS_RE = /\[[^[]*]/;
36
+ const REGEX_GROUP_SYMBOLS_RE = /(?:^|[^!*+?@])\([^(]*\|[^|]*\)/;
37
+ const GLOB_EXTENSION_SYMBOLS_RE = /[!*+?@]\([^(]*\)/;
38
+ const BRACE_EXPANSION_SEPARATORS_RE = /,|\.\./;
39
+ /**
40
+ * Matches a sequence of two or more consecutive slashes, excluding the first two slashes at the beginning of the string.
41
+ * The latter is due to the presence of the device path at the beginning of the UNC path.
42
+ */
43
+ const DOUBLE_SLASH_RE = /(?!^)\/{2,}/g;
44
+ function isStaticPattern(pattern, options = {}) {
45
+ return !isDynamicPattern(pattern, options);
46
+ }
47
+ function isDynamicPattern(pattern, options = {}) {
48
+ /**
49
+ * A special case with an empty string is necessary for matching patterns that start with a forward slash.
50
+ * An empty string cannot be a dynamic pattern.
51
+ * For example, the pattern `/lib/*` will be spread into parts: '', 'lib', '*'.
52
+ */
53
+ if (pattern === '') {
54
+ return false;
55
+ }
56
+ /**
57
+ * When the `caseSensitiveMatch` option is disabled, all patterns must be marked as dynamic, because we cannot check
58
+ * filepath directly (without read directory).
59
+ */
60
+ if (options.caseSensitiveMatch === false || pattern.includes(ESCAPE_SYMBOL)) {
61
+ return true;
62
+ }
63
+ if (COMMON_GLOB_SYMBOLS_RE.test(pattern) || REGEX_CHARACTER_CLASS_SYMBOLS_RE.test(pattern) || REGEX_GROUP_SYMBOLS_RE.test(pattern)) {
64
+ return true;
65
+ }
66
+ if (options.extglob !== false && GLOB_EXTENSION_SYMBOLS_RE.test(pattern)) {
67
+ return true;
68
+ }
69
+ if (options.braceExpansion !== false && hasBraceExpansion(pattern)) {
70
+ return true;
71
+ }
72
+ return false;
73
+ }
74
+ function hasBraceExpansion(pattern) {
75
+ const openingBraceIndex = pattern.indexOf('{');
76
+ if (openingBraceIndex === -1) {
77
+ return false;
78
+ }
79
+ const closingBraceIndex = pattern.indexOf('}', openingBraceIndex + 1);
80
+ if (closingBraceIndex === -1) {
81
+ return false;
82
+ }
83
+ const braceContent = pattern.slice(openingBraceIndex, closingBraceIndex);
84
+ return BRACE_EXPANSION_SEPARATORS_RE.test(braceContent);
85
+ }
86
+ function convertToPositivePattern(pattern) {
87
+ return isNegativePattern(pattern) ? pattern.slice(1) : pattern;
88
+ }
89
+ function convertToNegativePattern(pattern) {
90
+ return `!${pattern}`;
91
+ }
92
+ function isNegativePattern(pattern) {
93
+ return pattern.startsWith('!') && pattern[1] !== '(';
94
+ }
95
+ function isPositivePattern(pattern) {
96
+ return !isNegativePattern(pattern);
97
+ }
98
+ function getNegativePatterns(patterns) {
99
+ return patterns.filter((pattern) => isNegativePattern(pattern));
100
+ }
101
+ function getPositivePatterns(patterns) {
102
+ return patterns.filter((pattern) => isPositivePattern(pattern));
103
+ }
104
+ /**
105
+ * Returns patterns that can be applied inside the current directory.
106
+ *
107
+ * @example
108
+ * // ['./*', '*', 'a/*']
109
+ * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
110
+ */
111
+ function getPatternsInsideCurrentDirectory(patterns) {
112
+ return patterns.filter((pattern) => !isPatternRelatedToParentDirectory(pattern));
113
+ }
114
+ /**
115
+ * Returns patterns to be expanded relative to (outside) the current directory.
116
+ *
117
+ * @example
118
+ * // ['../*', './../*']
119
+ * getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*'])
120
+ */
121
+ function getPatternsOutsideCurrentDirectory(patterns) {
122
+ return patterns.filter((pattern) => isPatternRelatedToParentDirectory(pattern));
123
+ }
124
+ function isPatternRelatedToParentDirectory(pattern) {
125
+ return pattern.startsWith('..') || pattern.startsWith('./..');
126
+ }
127
+ function getBaseDirectory(pattern) {
128
+ return globParent(pattern, { flipBackslashes: false });
129
+ }
130
+ function hasGlobStar(pattern) {
131
+ return pattern.includes(GLOBSTAR);
132
+ }
133
+ function endsWithSlashGlobStar(pattern) {
134
+ return pattern.endsWith(`/${GLOBSTAR}`);
135
+ }
136
+ function isAffectDepthOfReadingPattern(pattern) {
137
+ const basename = path.basename(pattern);
138
+ return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
139
+ }
140
+ function expandPatternsWithBraceExpansion(patterns) {
141
+ return patterns.reduce((collection, pattern) => {
142
+ return collection.concat(expandBraceExpansion(pattern));
143
+ }, []);
144
+ }
145
+ function expandBraceExpansion(pattern) {
146
+ const patterns = micromatch.braces(pattern, { expand: true, nodupes: true, keepEscaping: true });
147
+ /**
148
+ * Sort the patterns by length so that the same depth patterns are processed side by side.
149
+ * `a/{b,}/{c,}/*` – `['a///*', 'a/b//*', 'a//c/*', 'a/b/c/*']`
150
+ */
151
+ patterns.sort((a, b) => a.length - b.length);
152
+ /**
153
+ * Micromatch can return an empty string in the case of patterns like `{a,}`.
154
+ */
155
+ return patterns.filter((pattern) => pattern !== '');
156
+ }
157
+ function getPatternParts(pattern, options) {
158
+ let { parts } = micromatch.scan(pattern, {
159
+ ...options,
160
+ parts: true,
161
+ });
162
+ /**
163
+ * The scan method returns an empty array in some cases.
164
+ * See micromatch/picomatch#58 for more details.
165
+ */
166
+ if (parts.length === 0) {
167
+ parts = [pattern];
168
+ }
169
+ /**
170
+ * The scan method does not return an empty part for the pattern with a forward slash.
171
+ * This is another part of micromatch/picomatch#58.
172
+ */
173
+ if (parts[0].startsWith('/')) {
174
+ parts[0] = parts[0].slice(1);
175
+ parts.unshift('');
176
+ }
177
+ return parts;
178
+ }
179
+ function makeRe(pattern, options) {
180
+ return micromatch.makeRe(pattern, options);
181
+ }
182
+ function convertPatternsToRe(patterns, options) {
183
+ return patterns.map((pattern) => makeRe(pattern, options));
184
+ }
185
+ function matchAny(entry, patternsRe) {
186
+ return patternsRe.some((patternRe) => patternRe.test(entry));
187
+ }
188
+ /**
189
+ * This package only works with forward slashes as a path separator.
190
+ * Because of this, we cannot use the standard `path.normalize` method, because on Windows platform it will use of backslashes.
191
+ */
192
+ function removeDuplicateSlashes(pattern) {
193
+ return pattern.replaceAll(DOUBLE_SLASH_RE, '/');
194
+ }
195
+ function partitionAbsoluteAndRelative(patterns) {
196
+ const absolute = [];
197
+ const relative = [];
198
+ for (const pattern of patterns) {
199
+ if (isAbsolute(pattern)) {
200
+ absolute.push(pattern);
201
+ }
202
+ else {
203
+ relative.push(pattern);
204
+ }
205
+ }
206
+ return [absolute, relative];
207
+ }
208
+ function isAbsolute(pattern) {
209
+ return path.isAbsolute(pattern);
210
+ }
@@ -0,0 +1,2 @@
1
+ import type { Readable } from 'node:stream';
2
+ export declare function merge(streams: Readable[]): NodeJS.ReadableStream;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.merge = merge;
4
+ // https://stackoverflow.com/a/39415662
5
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
6
+ const merge2 = require("merge2");
7
+ function merge(streams) {
8
+ const mergedStream = merge2(streams);
9
+ streams.forEach((stream) => {
10
+ stream.once('error', (error) => mergedStream.emit('error', error));
11
+ });
12
+ mergedStream.once('close', () => {
13
+ propagateCloseEventToSources(streams);
14
+ });
15
+ mergedStream.once('end', () => {
16
+ propagateCloseEventToSources(streams);
17
+ });
18
+ return mergedStream;
19
+ }
20
+ function propagateCloseEventToSources(streams) {
21
+ streams.forEach((stream) => stream.emit('close'));
22
+ }
@@ -0,0 +1,8 @@
1
+ export declare function isString(input: unknown): input is string;
2
+ export declare function isEmpty(input: string): boolean;
3
+ /**
4
+ * Flattens the underlying C structures of a concatenated JavaScript string.
5
+ *
6
+ * More details: https://github.com/davidmarkclements/flatstr
7
+ */
8
+ export declare function flatHeavilyConcatenatedString(input: string): string;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isString = isString;
4
+ exports.isEmpty = isEmpty;
5
+ exports.flatHeavilyConcatenatedString = flatHeavilyConcatenatedString;
6
+ function isString(input) {
7
+ return typeof input === 'string';
8
+ }
9
+ function isEmpty(input) {
10
+ return input === '';
11
+ }
12
+ /**
13
+ * Flattens the underlying C structures of a concatenated JavaScript string.
14
+ *
15
+ * More details: https://github.com/davidmarkclements/flatstr
16
+ */
17
+ function flatHeavilyConcatenatedString(input) {
18
+ // @ts-expect-error Another solution can be `.trim`, but it changes the string.
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions, no-bitwise, unicorn/prefer-math-trunc
20
+ input | 0;
21
+ return input;
22
+ }