format: prettify entire project

This commit is contained in:
Rim
2025-04-02 06:50:39 -04:00
parent 86f0782a98
commit 7ccc0be712
1711 changed files with 755867 additions and 235931 deletions

View File

@ -1,3 +1,3 @@
#!/usr/bin/env node
export {};
//# sourceMappingURL=bin.d.mts.map
//# sourceMappingURL=bin.d.mts.map

255
node_modules/glob/dist/esm/bin.mjs generated vendored
View File

@ -7,34 +7,36 @@ import { join } from 'path';
import { globStream } from './index.js';
const { version } = loadPackageJson(import.meta.url, '../package.json');
const j = jack({
usage: 'glob [options] [<pattern> [<pattern> ...]]',
usage: 'glob [options] [<pattern> [<pattern> ...]]',
})
.description(`
.description(
`
Glob v${version}
Expand the positional glob expression arguments into any matching file
system paths found.
`)
.opt({
`
)
.opt({
cmd: {
short: 'c',
hint: 'command',
description: `Run the command provided, passing the glob expression
short: 'c',
hint: 'command',
description: `Run the command provided, passing the glob expression
matches as arguments.`,
},
})
.opt({
})
.opt({
default: {
short: 'p',
hint: 'pattern',
description: `If no positional arguments are provided, glob will use
short: 'p',
hint: 'pattern',
description: `If no positional arguments are provided, glob will use
this pattern`,
},
})
.flag({
})
.flag({
all: {
short: 'A',
description: `By default, the glob cli command will not expand any
short: 'A',
description: `By default, the glob cli command will not expand any
arguments that are an exact match to a file on disk.
This prevents double-expanding, in case the shell expands
@ -58,20 +60,20 @@ const j = jack({
`,
},
absolute: {
short: 'a',
description: 'Expand to absolute paths',
short: 'a',
description: 'Expand to absolute paths',
},
'dot-relative': {
short: 'd',
description: `Prepend './' on relative matches`,
short: 'd',
description: `Prepend './' on relative matches`,
},
mark: {
short: 'm',
description: `Append a / on any directories matched`,
short: 'm',
description: `Append a / on any directories matched`,
},
posix: {
short: 'x',
description: `Always resolve to posix style paths, using '/' as the
short: 'x',
description: `Always resolve to posix style paths, using '/' as the
directory separator, even on Windows. Drive letter
absolute matches on Windows will be expanded to their
full resolved UNC maths, eg instead of 'C:\\foo\\bar',
@ -79,39 +81,39 @@ const j = jack({
`,
},
follow: {
short: 'f',
description: `Follow symlinked directories when expanding '**'`,
short: 'f',
description: `Follow symlinked directories when expanding '**'`,
},
realpath: {
short: 'R',
description: `Call 'fs.realpath' on all of the results. In the case
short: 'R',
description: `Call 'fs.realpath' on all of the results. In the case
of an entry that cannot be resolved, the entry is
omitted. This incurs a slight performance penalty, of
course, because of the added system calls.`,
},
stat: {
short: 's',
description: `Call 'fs.lstat' on all entries, whether required or not
short: 's',
description: `Call 'fs.lstat' on all entries, whether required or not
to determine if it's a valid match.`,
},
'match-base': {
short: 'b',
description: `Perform a basename-only match if the pattern does not
short: 'b',
description: `Perform a basename-only match if the pattern does not
contain any slash characters. That is, '*.js' would be
treated as equivalent to '**/*.js', matching js files
in all directories.
`,
},
dot: {
description: `Allow patterns to match files/directories that start
description: `Allow patterns to match files/directories that start
with '.', even if the pattern does not start with '.'
`,
},
nobrace: {
description: 'Do not expand {...} patterns',
description: 'Do not expand {...} patterns',
},
nocase: {
description: `Perform a case-insensitive match. This defaults to
description: `Perform a case-insensitive match. This defaults to
'true' on macOS and Windows platforms, and false on
all others.
@ -123,41 +125,41 @@ const j = jack({
`,
},
nodir: {
description: `Do not match directories, only files.
description: `Do not match directories, only files.
Note: to *only* match directories, append a '/' at the
end of the pattern.
`,
},
noext: {
description: `Do not expand extglob patterns, such as '+(a|b)'`,
description: `Do not expand extglob patterns, such as '+(a|b)'`,
},
noglobstar: {
description: `Do not expand '**' against multiple path portions.
description: `Do not expand '**' against multiple path portions.
Ie, treat it as a normal '*' instead.`,
},
'windows-path-no-escape': {
description: `Use '\\' as a path separator *only*, and *never* as an
description: `Use '\\' as a path separator *only*, and *never* as an
escape character. If set, all '\\' characters are
replaced with '/' in the pattern.`,
},
})
.num({
})
.num({
'max-depth': {
short: 'D',
description: `Maximum depth to traverse from the current
short: 'D',
description: `Maximum depth to traverse from the current
working directory`,
},
})
.opt({
})
.opt({
cwd: {
short: 'C',
description: 'Current working directory to execute/match in',
default: process.cwd(),
short: 'C',
description: 'Current working directory to execute/match in',
default: process.cwd(),
},
root: {
short: 'r',
description: `A string path resolved against the 'cwd', which is
short: 'r',
description: `A string path resolved against the 'cwd', which is
used as the starting point for absolute patterns that
start with '/' (but not drive letters or UNC paths
on Windows).
@ -179,92 +181,91 @@ const j = jack({
`,
},
platform: {
description: `Defaults to the value of 'process.platform' if
description: `Defaults to the value of 'process.platform' if
available, or 'linux' if not. Setting --platform=win32
on non-Windows systems may cause strange behavior!`,
validOptions: [
'aix',
'android',
'darwin',
'freebsd',
'haiku',
'linux',
'openbsd',
'sunos',
'win32',
'cygwin',
'netbsd',
],
validOptions: [
'aix',
'android',
'darwin',
'freebsd',
'haiku',
'linux',
'openbsd',
'sunos',
'win32',
'cygwin',
'netbsd',
],
},
})
.optList({
})
.optList({
ignore: {
short: 'i',
description: `Glob patterns to ignore`,
short: 'i',
description: `Glob patterns to ignore`,
},
})
.flag({
})
.flag({
debug: {
short: 'v',
description: `Output a huge amount of noisy debug information about
short: 'v',
description: `Output a huge amount of noisy debug information about
patterns as they are parsed and used to match files.`,
},
})
.flag({
})
.flag({
help: {
short: 'h',
description: 'Show this usage information',
short: 'h',
description: 'Show this usage information',
},
});
});
try {
const { positionals, values } = j.parse();
if (values.help) {
console.log(j.usage());
process.exit(0);
}
if (positionals.length === 0 && !values.default)
throw 'No patterns provided';
if (positionals.length === 0 && values.default)
positionals.push(values.default);
const patterns = values.all ? positionals : positionals.filter(p => !existsSync(p));
const matches = values.all ?
[]
: positionals.filter(p => existsSync(p)).map(p => join(p));
const stream = globStream(patterns, {
absolute: values.absolute,
cwd: values.cwd,
dot: values.dot,
dotRelative: values['dot-relative'],
follow: values.follow,
ignore: values.ignore,
mark: values.mark,
matchBase: values['match-base'],
maxDepth: values['max-depth'],
nobrace: values.nobrace,
nocase: values.nocase,
nodir: values.nodir,
noext: values.noext,
noglobstar: values.noglobstar,
platform: values.platform,
realpath: values.realpath,
root: values.root,
stat: values.stat,
debug: values.debug,
posix: values.posix,
});
const cmd = values.cmd;
if (!cmd) {
matches.forEach(m => console.log(m));
stream.on('data', f => console.log(f));
}
else {
stream.on('data', f => matches.push(f));
stream.on('end', () => foregroundChild(cmd, matches, { shell: true }));
}
const { positionals, values } = j.parse();
if (values.help) {
console.log(j.usage());
process.exit(0);
}
if (positionals.length === 0 && !values.default) throw 'No patterns provided';
if (positionals.length === 0 && values.default)
positionals.push(values.default);
const patterns =
values.all ? positionals : positionals.filter((p) => !existsSync(p));
const matches =
values.all ?
[]
: positionals.filter((p) => existsSync(p)).map((p) => join(p));
const stream = globStream(patterns, {
absolute: values.absolute,
cwd: values.cwd,
dot: values.dot,
dotRelative: values['dot-relative'],
follow: values.follow,
ignore: values.ignore,
mark: values.mark,
matchBase: values['match-base'],
maxDepth: values['max-depth'],
nobrace: values.nobrace,
nocase: values.nocase,
nodir: values.nodir,
noext: values.noext,
noglobstar: values.noglobstar,
platform: values.platform,
realpath: values.realpath,
root: values.root,
stat: values.stat,
debug: values.debug,
posix: values.posix,
});
const cmd = values.cmd;
if (!cmd) {
matches.forEach((m) => console.log(m));
stream.on('data', (f) => console.log(f));
} else {
stream.on('data', (f) => matches.push(f));
stream.on('end', () => foregroundChild(cmd, matches, { shell: true }));
}
} catch (e) {
console.error(j.usage());
console.error(e instanceof Error ? e.message : String(e));
process.exit(1);
}
catch (e) {
console.error(j.usage());
console.error(e instanceof Error ? e.message : String(e));
process.exit(1);
}
//# sourceMappingURL=bin.mjs.map
//# sourceMappingURL=bin.mjs.map

716
node_modules/glob/dist/esm/glob.d.ts generated vendored
View File

@ -19,370 +19,378 @@ export type GlobParts = Exclude<Minimatch['globParts'], undefined>;
* cache.
*/
export interface GlobOptions {
/**
* Set to `true` to always receive absolute paths for
* matched files. Set to `false` to always return relative paths.
*
* When this option is not set, absolute paths are returned for patterns
* that are absolute, and otherwise paths are returned that are relative
* to the `cwd` setting.
*
* This does _not_ make an extra system call to get
* the realpath, it only does string path resolution.
*
* Conflicts with {@link withFileTypes}
*/
absolute?: boolean;
/**
* Set to false to enable {@link windowsPathsNoEscape}
*
* @deprecated
*/
allowWindowsEscape?: boolean;
/**
* The current working directory in which to search. Defaults to
* `process.cwd()`.
*
* May be eiher a string path or a `file://` URL object or string.
*/
cwd?: string | URL;
/**
* Include `.dot` files in normal matches and `globstar`
* matches. Note that an explicit dot in a portion of the pattern
* will always match dot files.
*/
dot?: boolean;
/**
* Prepend all relative path strings with `./` (or `.\` on Windows).
*
* Without this option, returned relative paths are "bare", so instead of
* returning `'./foo/bar'`, they are returned as `'foo/bar'`.
*
* Relative patterns starting with `'../'` are not prepended with `./`, even
* if this option is set.
*/
dotRelative?: boolean;
/**
* Follow symlinked directories when expanding `**`
* patterns. This can result in a lot of duplicate references in
* the presence of cyclic links, and make performance quite bad.
*
* By default, a `**` in a pattern will follow 1 symbolic link if
* it is not the first item in the pattern, or none if it is the
* first item in the pattern, following the same behavior as Bash.
*/
follow?: boolean;
/**
* string or string[], or an object with `ignored` and `childrenIgnored`
* methods.
*
* If a string or string[] is provided, then this is treated as a glob
* pattern or array of glob patterns to exclude from matches. To ignore all
* children within a directory, as well as the entry itself, append `'/**'`
* to the ignore pattern.
*
* **Note** `ignore` patterns are _always_ in `dot:true` mode, regardless of
* any other settings.
*
* If an object is provided that has `ignored(path)` and/or
* `childrenIgnored(path)` methods, then these methods will be called to
* determine whether any Path is a match or if its children should be
* traversed, respectively.
*/
ignore?: string | string[] | IgnoreLike;
/**
* Treat brace expansion like `{a,b}` as a "magic" pattern. Has no
* effect if {@link nobrace} is set.
*
* Only has effect on the {@link hasMagic} function.
*/
magicalBraces?: boolean;
/**
* Add a `/` character to directory matches. Note that this requires
* additional stat calls in some cases.
*/
mark?: boolean;
/**
* Perform a basename-only match if the pattern does not contain any slash
* characters. That is, `*.js` would be treated as equivalent to
* `**\/*.js`, matching all js files in all directories.
*/
matchBase?: boolean;
/**
* Limit the directory traversal to a given depth below the cwd.
* Note that this does NOT prevent traversal to sibling folders,
* root patterns, and so on. It only limits the maximum folder depth
* that the walk will descend, relative to the cwd.
*/
maxDepth?: number;
/**
* Do not expand `{a,b}` and `{1..3}` brace sets.
*/
nobrace?: boolean;
/**
* Perform a case-insensitive match. This defaults to `true` on macOS and
* Windows systems, and `false` on all others.
*
* **Note** `nocase` should only be explicitly set when it is
* known that the filesystem's case sensitivity differs from the
* platform default. If set `true` on case-sensitive file
* systems, or `false` on case-insensitive file systems, then the
* walk may return more or less results than expected.
*/
nocase?: boolean;
/**
* Do not match directories, only files. (Note: to match
* _only_ directories, put a `/` at the end of the pattern.)
*/
nodir?: boolean;
/**
* Do not match "extglob" patterns such as `+(a|b)`.
*/
noext?: boolean;
/**
* Do not match `**` against multiple filenames. (Ie, treat it as a normal
* `*` instead.)
*
* Conflicts with {@link matchBase}
*/
noglobstar?: boolean;
/**
* Defaults to value of `process.platform` if available, or `'linux'` if
* not. Setting `platform:'win32'` on non-Windows systems may cause strange
* behavior.
*/
platform?: NodeJS.Platform;
/**
* Set to true to call `fs.realpath` on all of the
* results. In the case of an entry that cannot be resolved, the
* entry is omitted. This incurs a slight performance penalty, of
* course, because of the added system calls.
*/
realpath?: boolean;
/**
*
* A string path resolved against the `cwd` option, which
* is used as the starting point for absolute patterns that start
* with `/`, (but not drive letters or UNC paths on Windows).
*
* Note that this _doesn't_ necessarily limit the walk to the
* `root` directory, and doesn't affect the cwd starting point for
* non-absolute patterns. A pattern containing `..` will still be
* able to traverse out of the root directory, if it is not an
* actual root directory on the filesystem, and any non-absolute
* patterns will be matched in the `cwd`. For example, the
* pattern `/../*` with `{root:'/some/path'}` will return all
* files in `/some`, not all files in `/some/path`. The pattern
* `*` with `{root:'/some/path'}` will return all the entries in
* the cwd, not the entries in `/some/path`.
*
* To start absolute and non-absolute patterns in the same
* path, you can use `{root:''}`. However, be aware that on
* Windows systems, a pattern like `x:/*` or `//host/share/*` will
* _always_ start in the `x:/` or `//host/share` directory,
* regardless of the `root` setting.
*/
root?: string;
/**
* A [PathScurry](http://npm.im/path-scurry) object used
* to traverse the file system. If the `nocase` option is set
* explicitly, then any provided `scurry` object must match this
* setting.
*/
scurry?: PathScurry;
/**
* Call `lstat()` on all entries, whether required or not to determine
* if it's a valid match. When used with {@link withFileTypes}, this means
* that matches will include data such as modified time, permissions, and
* so on. Note that this will incur a performance cost due to the added
* system calls.
*/
stat?: boolean;
/**
* An AbortSignal which will cancel the Glob walk when
* triggered.
*/
signal?: AbortSignal;
/**
* Use `\\` as a path separator _only_, and
* _never_ as an escape character. If set, all `\\` characters are
* replaced with `/` in the pattern.
*
* Note that this makes it **impossible** to match against paths
* containing literal glob pattern characters, but allows matching
* with patterns constructed using `path.join()` and
* `path.resolve()` on Windows platforms, mimicking the (buggy!)
* behavior of Glob v7 and before on Windows. Please use with
* caution, and be mindful of [the caveat below about Windows
* paths](#windows). (For legacy reasons, this is also set if
* `allowWindowsEscape` is set to the exact value `false`.)
*/
windowsPathsNoEscape?: boolean;
/**
* Return [PathScurry](http://npm.im/path-scurry)
* `Path` objects instead of strings. These are similar to a
* NodeJS `Dirent` object, but with additional methods and
* properties.
*
* Conflicts with {@link absolute}
*/
withFileTypes?: boolean;
/**
* An fs implementation to override some or all of the defaults. See
* http://npm.im/path-scurry for details about what can be overridden.
*/
fs?: FSOption;
/**
* Just passed along to Minimatch. Note that this makes all pattern
* matching operations slower and *extremely* noisy.
*/
debug?: boolean;
/**
* Return `/` delimited paths, even on Windows.
*
* On posix systems, this has no effect. But, on Windows, it means that
* paths will be `/` delimited, and absolute paths will be their full
* resolved UNC forms, eg instead of `'C:\\foo\\bar'`, it would return
* `'//?/C:/foo/bar'`
*/
posix?: boolean;
/**
* Do not match any children of any matches. For example, the pattern
* `**\/foo` would match `a/foo`, but not `a/foo/b/foo` in this mode.
*
* This is especially useful for cases like "find all `node_modules`
* folders, but not the ones in `node_modules`".
*
* In order to support this, the `Ignore` implementation must support an
* `add(pattern: string)` method. If using the default `Ignore` class, then
* this is fine, but if this is set to `false`, and a custom `Ignore` is
* provided that does not have an `add()` method, then it will throw an
* error.
*
* **Caveat** It *only* ignores matches that would be a descendant of a
* previous match, and only if that descendant is matched *after* the
* ancestor is encountered. Since the file system walk happens in
* indeterminate order, it's possible that a match will already be added
* before its ancestor, if multiple or braced patterns are used.
*
* For example:
*
* ```ts
* const results = await glob([
* // likely to match first, since it's just a stat
* 'a/b/c/d/e/f',
*
* // this pattern is more complicated! It must to various readdir()
* // calls and test the results against a regular expression, and that
* // is certainly going to take a little bit longer.
* //
* // So, later on, it encounters a match at 'a/b/c/d/e', but it's too
* // late to ignore a/b/c/d/e/f, because it's already been emitted.
* 'a/[bdf]/?/[a-z]/*',
* ], { includeChildMatches: false })
* ```
*
* It's best to only set this to `false` if you can be reasonably sure that
* no components of the pattern will potentially match one another's file
* system descendants, or if the occasional included child entry will not
* cause problems.
*
* @default true
*/
includeChildMatches?: boolean;
/**
* Set to `true` to always receive absolute paths for
* matched files. Set to `false` to always return relative paths.
*
* When this option is not set, absolute paths are returned for patterns
* that are absolute, and otherwise paths are returned that are relative
* to the `cwd` setting.
*
* This does _not_ make an extra system call to get
* the realpath, it only does string path resolution.
*
* Conflicts with {@link withFileTypes}
*/
absolute?: boolean;
/**
* Set to false to enable {@link windowsPathsNoEscape}
*
* @deprecated
*/
allowWindowsEscape?: boolean;
/**
* The current working directory in which to search. Defaults to
* `process.cwd()`.
*
* May be eiher a string path or a `file://` URL object or string.
*/
cwd?: string | URL;
/**
* Include `.dot` files in normal matches and `globstar`
* matches. Note that an explicit dot in a portion of the pattern
* will always match dot files.
*/
dot?: boolean;
/**
* Prepend all relative path strings with `./` (or `.\` on Windows).
*
* Without this option, returned relative paths are "bare", so instead of
* returning `'./foo/bar'`, they are returned as `'foo/bar'`.
*
* Relative patterns starting with `'../'` are not prepended with `./`, even
* if this option is set.
*/
dotRelative?: boolean;
/**
* Follow symlinked directories when expanding `**`
* patterns. This can result in a lot of duplicate references in
* the presence of cyclic links, and make performance quite bad.
*
* By default, a `**` in a pattern will follow 1 symbolic link if
* it is not the first item in the pattern, or none if it is the
* first item in the pattern, following the same behavior as Bash.
*/
follow?: boolean;
/**
* string or string[], or an object with `ignored` and `childrenIgnored`
* methods.
*
* If a string or string[] is provided, then this is treated as a glob
* pattern or array of glob patterns to exclude from matches. To ignore all
* children within a directory, as well as the entry itself, append `'/**'`
* to the ignore pattern.
*
* **Note** `ignore` patterns are _always_ in `dot:true` mode, regardless of
* any other settings.
*
* If an object is provided that has `ignored(path)` and/or
* `childrenIgnored(path)` methods, then these methods will be called to
* determine whether any Path is a match or if its children should be
* traversed, respectively.
*/
ignore?: string | string[] | IgnoreLike;
/**
* Treat brace expansion like `{a,b}` as a "magic" pattern. Has no
* effect if {@link nobrace} is set.
*
* Only has effect on the {@link hasMagic} function.
*/
magicalBraces?: boolean;
/**
* Add a `/` character to directory matches. Note that this requires
* additional stat calls in some cases.
*/
mark?: boolean;
/**
* Perform a basename-only match if the pattern does not contain any slash
* characters. That is, `*.js` would be treated as equivalent to
* `**\/*.js`, matching all js files in all directories.
*/
matchBase?: boolean;
/**
* Limit the directory traversal to a given depth below the cwd.
* Note that this does NOT prevent traversal to sibling folders,
* root patterns, and so on. It only limits the maximum folder depth
* that the walk will descend, relative to the cwd.
*/
maxDepth?: number;
/**
* Do not expand `{a,b}` and `{1..3}` brace sets.
*/
nobrace?: boolean;
/**
* Perform a case-insensitive match. This defaults to `true` on macOS and
* Windows systems, and `false` on all others.
*
* **Note** `nocase` should only be explicitly set when it is
* known that the filesystem's case sensitivity differs from the
* platform default. If set `true` on case-sensitive file
* systems, or `false` on case-insensitive file systems, then the
* walk may return more or less results than expected.
*/
nocase?: boolean;
/**
* Do not match directories, only files. (Note: to match
* _only_ directories, put a `/` at the end of the pattern.)
*/
nodir?: boolean;
/**
* Do not match "extglob" patterns such as `+(a|b)`.
*/
noext?: boolean;
/**
* Do not match `**` against multiple filenames. (Ie, treat it as a normal
* `*` instead.)
*
* Conflicts with {@link matchBase}
*/
noglobstar?: boolean;
/**
* Defaults to value of `process.platform` if available, or `'linux'` if
* not. Setting `platform:'win32'` on non-Windows systems may cause strange
* behavior.
*/
platform?: NodeJS.Platform;
/**
* Set to true to call `fs.realpath` on all of the
* results. In the case of an entry that cannot be resolved, the
* entry is omitted. This incurs a slight performance penalty, of
* course, because of the added system calls.
*/
realpath?: boolean;
/**
*
* A string path resolved against the `cwd` option, which
* is used as the starting point for absolute patterns that start
* with `/`, (but not drive letters or UNC paths on Windows).
*
* Note that this _doesn't_ necessarily limit the walk to the
* `root` directory, and doesn't affect the cwd starting point for
* non-absolute patterns. A pattern containing `..` will still be
* able to traverse out of the root directory, if it is not an
* actual root directory on the filesystem, and any non-absolute
* patterns will be matched in the `cwd`. For example, the
* pattern `/../*` with `{root:'/some/path'}` will return all
* files in `/some`, not all files in `/some/path`. The pattern
* `*` with `{root:'/some/path'}` will return all the entries in
* the cwd, not the entries in `/some/path`.
*
* To start absolute and non-absolute patterns in the same
* path, you can use `{root:''}`. However, be aware that on
* Windows systems, a pattern like `x:/*` or `//host/share/*` will
* _always_ start in the `x:/` or `//host/share` directory,
* regardless of the `root` setting.
*/
root?: string;
/**
* A [PathScurry](http://npm.im/path-scurry) object used
* to traverse the file system. If the `nocase` option is set
* explicitly, then any provided `scurry` object must match this
* setting.
*/
scurry?: PathScurry;
/**
* Call `lstat()` on all entries, whether required or not to determine
* if it's a valid match. When used with {@link withFileTypes}, this means
* that matches will include data such as modified time, permissions, and
* so on. Note that this will incur a performance cost due to the added
* system calls.
*/
stat?: boolean;
/**
* An AbortSignal which will cancel the Glob walk when
* triggered.
*/
signal?: AbortSignal;
/**
* Use `\\` as a path separator _only_, and
* _never_ as an escape character. If set, all `\\` characters are
* replaced with `/` in the pattern.
*
* Note that this makes it **impossible** to match against paths
* containing literal glob pattern characters, but allows matching
* with patterns constructed using `path.join()` and
* `path.resolve()` on Windows platforms, mimicking the (buggy!)
* behavior of Glob v7 and before on Windows. Please use with
* caution, and be mindful of [the caveat below about Windows
* paths](#windows). (For legacy reasons, this is also set if
* `allowWindowsEscape` is set to the exact value `false`.)
*/
windowsPathsNoEscape?: boolean;
/**
* Return [PathScurry](http://npm.im/path-scurry)
* `Path` objects instead of strings. These are similar to a
* NodeJS `Dirent` object, but with additional methods and
* properties.
*
* Conflicts with {@link absolute}
*/
withFileTypes?: boolean;
/**
* An fs implementation to override some or all of the defaults. See
* http://npm.im/path-scurry for details about what can be overridden.
*/
fs?: FSOption;
/**
* Just passed along to Minimatch. Note that this makes all pattern
* matching operations slower and *extremely* noisy.
*/
debug?: boolean;
/**
* Return `/` delimited paths, even on Windows.
*
* On posix systems, this has no effect. But, on Windows, it means that
* paths will be `/` delimited, and absolute paths will be their full
* resolved UNC forms, eg instead of `'C:\\foo\\bar'`, it would return
* `'//?/C:/foo/bar'`
*/
posix?: boolean;
/**
* Do not match any children of any matches. For example, the pattern
* `**\/foo` would match `a/foo`, but not `a/foo/b/foo` in this mode.
*
* This is especially useful for cases like "find all `node_modules`
* folders, but not the ones in `node_modules`".
*
* In order to support this, the `Ignore` implementation must support an
* `add(pattern: string)` method. If using the default `Ignore` class, then
* this is fine, but if this is set to `false`, and a custom `Ignore` is
* provided that does not have an `add()` method, then it will throw an
* error.
*
* **Caveat** It *only* ignores matches that would be a descendant of a
* previous match, and only if that descendant is matched *after* the
* ancestor is encountered. Since the file system walk happens in
* indeterminate order, it's possible that a match will already be added
* before its ancestor, if multiple or braced patterns are used.
*
* For example:
*
* ```ts
* const results = await glob([
* // likely to match first, since it's just a stat
* 'a/b/c/d/e/f',
*
* // this pattern is more complicated! It must to various readdir()
* // calls and test the results against a regular expression, and that
* // is certainly going to take a little bit longer.
* //
* // So, later on, it encounters a match at 'a/b/c/d/e', but it's too
* // late to ignore a/b/c/d/e/f, because it's already been emitted.
* 'a/[bdf]/?/[a-z]/*',
* ], { includeChildMatches: false })
* ```
*
* It's best to only set this to `false` if you can be reasonably sure that
* no components of the pattern will potentially match one another's file
* system descendants, or if the occasional included child entry will not
* cause problems.
*
* @default true
*/
includeChildMatches?: boolean;
}
export type GlobOptionsWithFileTypesTrue = GlobOptions & {
withFileTypes: true;
absolute?: undefined;
mark?: undefined;
posix?: undefined;
withFileTypes: true;
absolute?: undefined;
mark?: undefined;
posix?: undefined;
};
export type GlobOptionsWithFileTypesFalse = GlobOptions & {
withFileTypes?: false;
withFileTypes?: false;
};
export type GlobOptionsWithFileTypesUnset = GlobOptions & {
withFileTypes?: undefined;
withFileTypes?: undefined;
};
export type Result<Opts> = Opts extends GlobOptionsWithFileTypesTrue ? Path : Opts extends GlobOptionsWithFileTypesFalse ? string : Opts extends GlobOptionsWithFileTypesUnset ? string : string | Path;
export type Result<Opts> =
Opts extends GlobOptionsWithFileTypesTrue ? Path
: Opts extends GlobOptionsWithFileTypesFalse ? string
: Opts extends GlobOptionsWithFileTypesUnset ? string
: string | Path;
export type Results<Opts> = Result<Opts>[];
export type FileTypes<Opts> = Opts extends GlobOptionsWithFileTypesTrue ? true : Opts extends GlobOptionsWithFileTypesFalse ? false : Opts extends GlobOptionsWithFileTypesUnset ? false : boolean;
export type FileTypes<Opts> =
Opts extends GlobOptionsWithFileTypesTrue ? true
: Opts extends GlobOptionsWithFileTypesFalse ? false
: Opts extends GlobOptionsWithFileTypesUnset ? false
: boolean;
/**
* An object that can perform glob pattern traversals.
*/
export declare class Glob<Opts extends GlobOptions> implements GlobOptions {
absolute?: boolean;
cwd: string;
root?: string;
dot: boolean;
dotRelative: boolean;
follow: boolean;
ignore?: string | string[] | IgnoreLike;
magicalBraces: boolean;
mark?: boolean;
matchBase: boolean;
maxDepth: number;
nobrace: boolean;
nocase: boolean;
nodir: boolean;
noext: boolean;
noglobstar: boolean;
pattern: string[];
platform: NodeJS.Platform;
realpath: boolean;
scurry: PathScurry;
stat: boolean;
signal?: AbortSignal;
windowsPathsNoEscape: boolean;
withFileTypes: FileTypes<Opts>;
includeChildMatches: boolean;
/**
* The options provided to the constructor.
*/
opts: Opts;
/**
* An array of parsed immutable {@link Pattern} objects.
*/
patterns: Pattern[];
/**
* All options are stored as properties on the `Glob` object.
*
* See {@link GlobOptions} for full options descriptions.
*
* Note that a previous `Glob` object can be passed as the
* `GlobOptions` to another `Glob` instantiation to re-use settings
* and caches with a new pattern.
*
* Traversal functions can be called multiple times to run the walk
* again.
*/
constructor(pattern: string | string[], opts: Opts);
/**
* Returns a Promise that resolves to the results array.
*/
walk(): Promise<Results<Opts>>;
/**
* synchronous {@link Glob.walk}
*/
walkSync(): Results<Opts>;
/**
* Stream results asynchronously.
*/
stream(): Minipass<Result<Opts>, Result<Opts>>;
/**
* Stream results synchronously.
*/
streamSync(): Minipass<Result<Opts>, Result<Opts>>;
/**
* Default sync iteration function. Returns a Generator that
* iterates over the results.
*/
iterateSync(): Generator<Result<Opts>, void, void>;
[Symbol.iterator](): Generator<Result<Opts>, void, void>;
/**
* Default async iteration function. Returns an AsyncGenerator that
* iterates over the results.
*/
iterate(): AsyncGenerator<Result<Opts>, void, void>;
[Symbol.asyncIterator](): AsyncGenerator<Result<Opts>, void, void>;
absolute?: boolean;
cwd: string;
root?: string;
dot: boolean;
dotRelative: boolean;
follow: boolean;
ignore?: string | string[] | IgnoreLike;
magicalBraces: boolean;
mark?: boolean;
matchBase: boolean;
maxDepth: number;
nobrace: boolean;
nocase: boolean;
nodir: boolean;
noext: boolean;
noglobstar: boolean;
pattern: string[];
platform: NodeJS.Platform;
realpath: boolean;
scurry: PathScurry;
stat: boolean;
signal?: AbortSignal;
windowsPathsNoEscape: boolean;
withFileTypes: FileTypes<Opts>;
includeChildMatches: boolean;
/**
* The options provided to the constructor.
*/
opts: Opts;
/**
* An array of parsed immutable {@link Pattern} objects.
*/
patterns: Pattern[];
/**
* All options are stored as properties on the `Glob` object.
*
* See {@link GlobOptions} for full options descriptions.
*
* Note that a previous `Glob` object can be passed as the
* `GlobOptions` to another `Glob` instantiation to re-use settings
* and caches with a new pattern.
*
* Traversal functions can be called multiple times to run the walk
* again.
*/
constructor(pattern: string | string[], opts: Opts);
/**
* Returns a Promise that resolves to the results array.
*/
walk(): Promise<Results<Opts>>;
/**
* synchronous {@link Glob.walk}
*/
walkSync(): Results<Opts>;
/**
* Stream results asynchronously.
*/
stream(): Minipass<Result<Opts>, Result<Opts>>;
/**
* Stream results synchronously.
*/
streamSync(): Minipass<Result<Opts>, Result<Opts>>;
/**
* Default sync iteration function. Returns a Generator that
* iterates over the results.
*/
iterateSync(): Generator<Result<Opts>, void, void>;
[Symbol.iterator](): Generator<Result<Opts>, void, void>;
/**
* Default async iteration function. Returns an AsyncGenerator that
* iterates over the results.
*/
iterate(): AsyncGenerator<Result<Opts>, void, void>;
[Symbol.asyncIterator](): AsyncGenerator<Result<Opts>, void, void>;
}
//# sourceMappingURL=glob.d.ts.map
//# sourceMappingURL=glob.d.ts.map

458
node_modules/glob/dist/esm/glob.js generated vendored
View File

@ -1,243 +1,253 @@
import { Minimatch } from 'minimatch';
import { fileURLToPath } from 'node:url';
import { PathScurry, PathScurryDarwin, PathScurryPosix, PathScurryWin32, } from 'path-scurry';
import {
PathScurry,
PathScurryDarwin,
PathScurryPosix,
PathScurryWin32,
} from 'path-scurry';
import { Pattern } from './pattern.js';
import { GlobStream, GlobWalker } from './walker.js';
// if no process global, just call it linux.
// so we default to case-sensitive, / separators
const defaultPlatform = (typeof process === 'object' &&
const defaultPlatform =
(
typeof process === 'object' &&
process &&
typeof process.platform === 'string') ?
typeof process.platform === 'string'
) ?
process.platform
: 'linux';
: 'linux';
/**
* An object that can perform glob pattern traversals.
*/
export class Glob {
absolute;
cwd;
root;
dot;
dotRelative;
follow;
ignore;
magicalBraces;
mark;
matchBase;
maxDepth;
nobrace;
nocase;
nodir;
noext;
noglobstar;
pattern;
platform;
realpath;
scurry;
stat;
signal;
windowsPathsNoEscape;
withFileTypes;
includeChildMatches;
/**
* The options provided to the constructor.
*/
opts;
/**
* An array of parsed immutable {@link Pattern} objects.
*/
patterns;
/**
* All options are stored as properties on the `Glob` object.
*
* See {@link GlobOptions} for full options descriptions.
*
* Note that a previous `Glob` object can be passed as the
* `GlobOptions` to another `Glob` instantiation to re-use settings
* and caches with a new pattern.
*
* Traversal functions can be called multiple times to run the walk
* again.
*/
constructor(pattern, opts) {
/* c8 ignore start */
if (!opts)
throw new TypeError('glob options required');
/* c8 ignore stop */
this.withFileTypes = !!opts.withFileTypes;
this.signal = opts.signal;
this.follow = !!opts.follow;
this.dot = !!opts.dot;
this.dotRelative = !!opts.dotRelative;
this.nodir = !!opts.nodir;
this.mark = !!opts.mark;
if (!opts.cwd) {
this.cwd = '';
}
else if (opts.cwd instanceof URL || opts.cwd.startsWith('file://')) {
opts.cwd = fileURLToPath(opts.cwd);
}
this.cwd = opts.cwd || '';
this.root = opts.root;
this.magicalBraces = !!opts.magicalBraces;
this.nobrace = !!opts.nobrace;
this.noext = !!opts.noext;
this.realpath = !!opts.realpath;
this.absolute = opts.absolute;
this.includeChildMatches = opts.includeChildMatches !== false;
this.noglobstar = !!opts.noglobstar;
this.matchBase = !!opts.matchBase;
this.maxDepth =
typeof opts.maxDepth === 'number' ? opts.maxDepth : Infinity;
this.stat = !!opts.stat;
this.ignore = opts.ignore;
if (this.withFileTypes && this.absolute !== undefined) {
throw new Error('cannot set absolute and withFileTypes:true');
}
if (typeof pattern === 'string') {
pattern = [pattern];
}
this.windowsPathsNoEscape =
!!opts.windowsPathsNoEscape ||
opts.allowWindowsEscape ===
false;
if (this.windowsPathsNoEscape) {
pattern = pattern.map(p => p.replace(/\\/g, '/'));
}
if (this.matchBase) {
if (opts.noglobstar) {
throw new TypeError('base matching requires globstar');
}
pattern = pattern.map(p => (p.includes('/') ? p : `./**/${p}`));
}
this.pattern = pattern;
this.platform = opts.platform || defaultPlatform;
this.opts = { ...opts, platform: this.platform };
if (opts.scurry) {
this.scurry = opts.scurry;
if (opts.nocase !== undefined &&
opts.nocase !== opts.scurry.nocase) {
throw new Error('nocase option contradicts provided scurry option');
}
}
else {
const Scurry = opts.platform === 'win32' ? PathScurryWin32
: opts.platform === 'darwin' ? PathScurryDarwin
: opts.platform ? PathScurryPosix
: PathScurry;
this.scurry = new Scurry(this.cwd, {
nocase: opts.nocase,
fs: opts.fs,
});
}
this.nocase = this.scurry.nocase;
// If you do nocase:true on a case-sensitive file system, then
// we need to use regexps instead of strings for non-magic
// path portions, because statting `aBc` won't return results
// for the file `AbC` for example.
const nocaseMagicOnly = this.platform === 'darwin' || this.platform === 'win32';
const mmo = {
// default nocase based on platform
...opts,
dot: this.dot,
matchBase: this.matchBase,
nobrace: this.nobrace,
nocase: this.nocase,
nocaseMagicOnly,
nocomment: true,
noext: this.noext,
nonegate: true,
optimizationLevel: 2,
platform: this.platform,
windowsPathsNoEscape: this.windowsPathsNoEscape,
debug: !!this.opts.debug,
};
const mms = this.pattern.map(p => new Minimatch(p, mmo));
const [matchSet, globParts] = mms.reduce((set, m) => {
set[0].push(...m.set);
set[1].push(...m.globParts);
return set;
}, [[], []]);
this.patterns = matchSet.map((set, i) => {
const g = globParts[i];
/* c8 ignore start */
if (!g)
throw new Error('invalid pattern object');
/* c8 ignore stop */
return new Pattern(set, g, 0, this.platform);
});
absolute;
cwd;
root;
dot;
dotRelative;
follow;
ignore;
magicalBraces;
mark;
matchBase;
maxDepth;
nobrace;
nocase;
nodir;
noext;
noglobstar;
pattern;
platform;
realpath;
scurry;
stat;
signal;
windowsPathsNoEscape;
withFileTypes;
includeChildMatches;
/**
* The options provided to the constructor.
*/
opts;
/**
* An array of parsed immutable {@link Pattern} objects.
*/
patterns;
/**
* All options are stored as properties on the `Glob` object.
*
* See {@link GlobOptions} for full options descriptions.
*
* Note that a previous `Glob` object can be passed as the
* `GlobOptions` to another `Glob` instantiation to re-use settings
* and caches with a new pattern.
*
* Traversal functions can be called multiple times to run the walk
* again.
*/
constructor(pattern, opts) {
/* c8 ignore start */
if (!opts) throw new TypeError('glob options required');
/* c8 ignore stop */
this.withFileTypes = !!opts.withFileTypes;
this.signal = opts.signal;
this.follow = !!opts.follow;
this.dot = !!opts.dot;
this.dotRelative = !!opts.dotRelative;
this.nodir = !!opts.nodir;
this.mark = !!opts.mark;
if (!opts.cwd) {
this.cwd = '';
} else if (opts.cwd instanceof URL || opts.cwd.startsWith('file://')) {
opts.cwd = fileURLToPath(opts.cwd);
}
async walk() {
// Walkers always return array of Path objects, so we just have to
// coerce them into the right shape. It will have already called
// realpath() if the option was set to do so, so we know that's cached.
// start out knowing the cwd, at least
return [
...(await new GlobWalker(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth: this.maxDepth !== Infinity ?
this.maxDepth + this.scurry.cwd.depth()
: Infinity,
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches,
}).walk()),
];
this.cwd = opts.cwd || '';
this.root = opts.root;
this.magicalBraces = !!opts.magicalBraces;
this.nobrace = !!opts.nobrace;
this.noext = !!opts.noext;
this.realpath = !!opts.realpath;
this.absolute = opts.absolute;
this.includeChildMatches = opts.includeChildMatches !== false;
this.noglobstar = !!opts.noglobstar;
this.matchBase = !!opts.matchBase;
this.maxDepth =
typeof opts.maxDepth === 'number' ? opts.maxDepth : Infinity;
this.stat = !!opts.stat;
this.ignore = opts.ignore;
if (this.withFileTypes && this.absolute !== undefined) {
throw new Error('cannot set absolute and withFileTypes:true');
}
walkSync() {
return [
...new GlobWalker(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth: this.maxDepth !== Infinity ?
this.maxDepth + this.scurry.cwd.depth()
: Infinity,
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches,
}).walkSync(),
];
if (typeof pattern === 'string') {
pattern = [pattern];
}
stream() {
return new GlobStream(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth: this.maxDepth !== Infinity ?
this.maxDepth + this.scurry.cwd.depth()
: Infinity,
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches,
}).stream();
this.windowsPathsNoEscape =
!!opts.windowsPathsNoEscape || opts.allowWindowsEscape === false;
if (this.windowsPathsNoEscape) {
pattern = pattern.map((p) => p.replace(/\\/g, '/'));
}
streamSync() {
return new GlobStream(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth: this.maxDepth !== Infinity ?
this.maxDepth + this.scurry.cwd.depth()
: Infinity,
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches,
}).streamSync();
if (this.matchBase) {
if (opts.noglobstar) {
throw new TypeError('base matching requires globstar');
}
pattern = pattern.map((p) => (p.includes('/') ? p : `./**/${p}`));
}
/**
* Default sync iteration function. Returns a Generator that
* iterates over the results.
*/
iterateSync() {
return this.streamSync()[Symbol.iterator]();
}
[Symbol.iterator]() {
return this.iterateSync();
}
/**
* Default async iteration function. Returns an AsyncGenerator that
* iterates over the results.
*/
iterate() {
return this.stream()[Symbol.asyncIterator]();
}
[Symbol.asyncIterator]() {
return this.iterate();
this.pattern = pattern;
this.platform = opts.platform || defaultPlatform;
this.opts = { ...opts, platform: this.platform };
if (opts.scurry) {
this.scurry = opts.scurry;
if (opts.nocase !== undefined && opts.nocase !== opts.scurry.nocase) {
throw new Error('nocase option contradicts provided scurry option');
}
} else {
const Scurry =
opts.platform === 'win32' ? PathScurryWin32
: opts.platform === 'darwin' ? PathScurryDarwin
: opts.platform ? PathScurryPosix
: PathScurry;
this.scurry = new Scurry(this.cwd, {
nocase: opts.nocase,
fs: opts.fs,
});
}
this.nocase = this.scurry.nocase;
// If you do nocase:true on a case-sensitive file system, then
// we need to use regexps instead of strings for non-magic
// path portions, because statting `aBc` won't return results
// for the file `AbC` for example.
const nocaseMagicOnly =
this.platform === 'darwin' || this.platform === 'win32';
const mmo = {
// default nocase based on platform
...opts,
dot: this.dot,
matchBase: this.matchBase,
nobrace: this.nobrace,
nocase: this.nocase,
nocaseMagicOnly,
nocomment: true,
noext: this.noext,
nonegate: true,
optimizationLevel: 2,
platform: this.platform,
windowsPathsNoEscape: this.windowsPathsNoEscape,
debug: !!this.opts.debug,
};
const mms = this.pattern.map((p) => new Minimatch(p, mmo));
const [matchSet, globParts] = mms.reduce(
(set, m) => {
set[0].push(...m.set);
set[1].push(...m.globParts);
return set;
},
[[], []]
);
this.patterns = matchSet.map((set, i) => {
const g = globParts[i];
/* c8 ignore start */
if (!g) throw new Error('invalid pattern object');
/* c8 ignore stop */
return new Pattern(set, g, 0, this.platform);
});
}
async walk() {
// Walkers always return array of Path objects, so we just have to
// coerce them into the right shape. It will have already called
// realpath() if the option was set to do so, so we know that's cached.
// start out knowing the cwd, at least
return [
...(await new GlobWalker(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth:
this.maxDepth !== Infinity ?
this.maxDepth + this.scurry.cwd.depth()
: Infinity,
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches,
}).walk()),
];
}
walkSync() {
return [
...new GlobWalker(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth:
this.maxDepth !== Infinity ?
this.maxDepth + this.scurry.cwd.depth()
: Infinity,
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches,
}).walkSync(),
];
}
stream() {
return new GlobStream(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth:
this.maxDepth !== Infinity ?
this.maxDepth + this.scurry.cwd.depth()
: Infinity,
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches,
}).stream();
}
streamSync() {
return new GlobStream(this.patterns, this.scurry.cwd, {
...this.opts,
maxDepth:
this.maxDepth !== Infinity ?
this.maxDepth + this.scurry.cwd.depth()
: Infinity,
platform: this.platform,
nocase: this.nocase,
includeChildMatches: this.includeChildMatches,
}).streamSync();
}
/**
* Default sync iteration function. Returns a Generator that
* iterates over the results.
*/
iterateSync() {
return this.streamSync()[Symbol.iterator]();
}
[Symbol.iterator]() {
return this.iterateSync();
}
/**
* Default async iteration function. Returns an AsyncGenerator that
* iterates over the results.
*/
iterate() {
return this.stream()[Symbol.asyncIterator]();
}
[Symbol.asyncIterator]() {
return this.iterate();
}
}
//# sourceMappingURL=glob.js.map
//# sourceMappingURL=glob.js.map

View File

@ -10,5 +10,8 @@ import { GlobOptions } from './glob.js';
* same as if you had called it on `['xay', 'xby']`. When `magicalBraces:true`
* is in the options, brace expansion _is_ treated as a pattern having magic.
*/
export declare const hasMagic: (pattern: string | string[], options?: GlobOptions) => boolean;
//# sourceMappingURL=has-magic.d.ts.map
export declare const hasMagic: (
pattern: string | string[],
options?: GlobOptions
) => boolean;
//# sourceMappingURL=has-magic.d.ts.map

View File

@ -11,13 +11,12 @@ import { Minimatch } from 'minimatch';
* is in the options, brace expansion _is_ treated as a pattern having magic.
*/
export const hasMagic = (pattern, options = {}) => {
if (!Array.isArray(pattern)) {
pattern = [pattern];
}
for (const p of pattern) {
if (new Minimatch(p, options).hasMagic())
return true;
}
return false;
if (!Array.isArray(pattern)) {
pattern = [pattern];
}
for (const p of pattern) {
if (new Minimatch(p, options).hasMagic()) return true;
}
return false;
};
//# sourceMappingURL=has-magic.js.map
//# sourceMappingURL=has-magic.js.map

View File

@ -2,23 +2,26 @@ import { Minimatch, MinimatchOptions } from 'minimatch';
import { Path } from 'path-scurry';
import { GlobWalkerOpts } from './walker.js';
export interface IgnoreLike {
ignored?: (p: Path) => boolean;
childrenIgnored?: (p: Path) => boolean;
add?: (ignore: string) => void;
ignored?: (p: Path) => boolean;
childrenIgnored?: (p: Path) => boolean;
add?: (ignore: string) => void;
}
/**
* Class used to process ignored patterns
*/
export declare class Ignore implements IgnoreLike {
relative: Minimatch[];
relativeChildren: Minimatch[];
absolute: Minimatch[];
absoluteChildren: Minimatch[];
platform: NodeJS.Platform;
mmopts: MinimatchOptions;
constructor(ignored: string[], { nobrace, nocase, noext, noglobstar, platform, }: GlobWalkerOpts);
add(ign: string): void;
ignored(p: Path): boolean;
childrenIgnored(p: Path): boolean;
relative: Minimatch[];
relativeChildren: Minimatch[];
absolute: Minimatch[];
absoluteChildren: Minimatch[];
platform: NodeJS.Platform;
mmopts: MinimatchOptions;
constructor(
ignored: string[],
{ nobrace, nocase, noext, noglobstar, platform }: GlobWalkerOpts
);
add(ign: string): void;
ignored(p: Path): boolean;
childrenIgnored(p: Path): boolean;
}
//# sourceMappingURL=ignore.d.ts.map
//# sourceMappingURL=ignore.d.ts.map

193
node_modules/glob/dist/esm/ignore.js generated vendored
View File

@ -4,112 +4,109 @@
// Ignores are always parsed in dot:true mode
import { Minimatch } from 'minimatch';
import { Pattern } from './pattern.js';
const defaultPlatform = (typeof process === 'object' &&
const defaultPlatform =
(
typeof process === 'object' &&
process &&
typeof process.platform === 'string') ?
typeof process.platform === 'string'
) ?
process.platform
: 'linux';
: 'linux';
/**
* Class used to process ignored patterns
*/
export class Ignore {
relative;
relativeChildren;
absolute;
absoluteChildren;
platform;
mmopts;
constructor(ignored, { nobrace, nocase, noext, noglobstar, platform = defaultPlatform, }) {
this.relative = [];
this.absolute = [];
this.relativeChildren = [];
this.absoluteChildren = [];
this.platform = platform;
this.mmopts = {
dot: true,
nobrace,
nocase,
noext,
noglobstar,
optimizationLevel: 2,
platform,
nocomment: true,
nonegate: true,
};
for (const ign of ignored)
this.add(ign);
relative;
relativeChildren;
absolute;
absoluteChildren;
platform;
mmopts;
constructor(
ignored,
{ nobrace, nocase, noext, noglobstar, platform = defaultPlatform }
) {
this.relative = [];
this.absolute = [];
this.relativeChildren = [];
this.absoluteChildren = [];
this.platform = platform;
this.mmopts = {
dot: true,
nobrace,
nocase,
noext,
noglobstar,
optimizationLevel: 2,
platform,
nocomment: true,
nonegate: true,
};
for (const ign of ignored) this.add(ign);
}
add(ign) {
// this is a little weird, but it gives us a clean set of optimized
// minimatch matchers, without getting tripped up if one of them
// ends in /** inside a brace section, and it's only inefficient at
// the start of the walk, not along it.
// It'd be nice if the Pattern class just had a .test() method, but
// handling globstars is a bit of a pita, and that code already lives
// in minimatch anyway.
// Another way would be if maybe Minimatch could take its set/globParts
// as an option, and then we could at least just use Pattern to test
// for absolute-ness.
// Yet another way, Minimatch could take an array of glob strings, and
// a cwd option, and do the right thing.
const mm = new Minimatch(ign, this.mmopts);
for (let i = 0; i < mm.set.length; i++) {
const parsed = mm.set[i];
const globParts = mm.globParts[i];
/* c8 ignore start */
if (!parsed || !globParts) {
throw new Error('invalid pattern object');
}
// strip off leading ./ portions
// https://github.com/isaacs/node-glob/issues/570
while (parsed[0] === '.' && globParts[0] === '.') {
parsed.shift();
globParts.shift();
}
/* c8 ignore stop */
const p = new Pattern(parsed, globParts, 0, this.platform);
const m = new Minimatch(p.globString(), this.mmopts);
const children = globParts[globParts.length - 1] === '**';
const absolute = p.isAbsolute();
if (absolute) this.absolute.push(m);
else this.relative.push(m);
if (children) {
if (absolute) this.absoluteChildren.push(m);
else this.relativeChildren.push(m);
}
}
add(ign) {
// this is a little weird, but it gives us a clean set of optimized
// minimatch matchers, without getting tripped up if one of them
// ends in /** inside a brace section, and it's only inefficient at
// the start of the walk, not along it.
// It'd be nice if the Pattern class just had a .test() method, but
// handling globstars is a bit of a pita, and that code already lives
// in minimatch anyway.
// Another way would be if maybe Minimatch could take its set/globParts
// as an option, and then we could at least just use Pattern to test
// for absolute-ness.
// Yet another way, Minimatch could take an array of glob strings, and
// a cwd option, and do the right thing.
const mm = new Minimatch(ign, this.mmopts);
for (let i = 0; i < mm.set.length; i++) {
const parsed = mm.set[i];
const globParts = mm.globParts[i];
/* c8 ignore start */
if (!parsed || !globParts) {
throw new Error('invalid pattern object');
}
// strip off leading ./ portions
// https://github.com/isaacs/node-glob/issues/570
while (parsed[0] === '.' && globParts[0] === '.') {
parsed.shift();
globParts.shift();
}
/* c8 ignore stop */
const p = new Pattern(parsed, globParts, 0, this.platform);
const m = new Minimatch(p.globString(), this.mmopts);
const children = globParts[globParts.length - 1] === '**';
const absolute = p.isAbsolute();
if (absolute)
this.absolute.push(m);
else
this.relative.push(m);
if (children) {
if (absolute)
this.absoluteChildren.push(m);
else
this.relativeChildren.push(m);
}
}
}
ignored(p) {
const fullpath = p.fullpath();
const fullpaths = `${fullpath}/`;
const relative = p.relative() || '.';
const relatives = `${relative}/`;
for (const m of this.relative) {
if (m.match(relative) || m.match(relatives)) return true;
}
ignored(p) {
const fullpath = p.fullpath();
const fullpaths = `${fullpath}/`;
const relative = p.relative() || '.';
const relatives = `${relative}/`;
for (const m of this.relative) {
if (m.match(relative) || m.match(relatives))
return true;
}
for (const m of this.absolute) {
if (m.match(fullpath) || m.match(fullpaths))
return true;
}
return false;
for (const m of this.absolute) {
if (m.match(fullpath) || m.match(fullpaths)) return true;
}
childrenIgnored(p) {
const fullpath = p.fullpath() + '/';
const relative = (p.relative() || '.') + '/';
for (const m of this.relativeChildren) {
if (m.match(relative))
return true;
}
for (const m of this.absoluteChildren) {
if (m.match(fullpath))
return true;
}
return false;
return false;
}
childrenIgnored(p) {
const fullpath = p.fullpath() + '/';
const relative = (p.relative() || '.') + '/';
for (const m of this.relativeChildren) {
if (m.match(relative)) return true;
}
for (const m of this.absoluteChildren) {
if (m.match(fullpath)) return true;
}
return false;
}
}
//# sourceMappingURL=ignore.js.map
//# sourceMappingURL=ignore.js.map

206
node_modules/glob/dist/esm/index.d.ts generated vendored
View File

@ -1,11 +1,27 @@
import { Minipass } from 'minipass';
import { Path } from 'path-scurry';
import type { GlobOptions, GlobOptionsWithFileTypesFalse, GlobOptionsWithFileTypesTrue, GlobOptionsWithFileTypesUnset } from './glob.js';
import type {
GlobOptions,
GlobOptionsWithFileTypesFalse,
GlobOptionsWithFileTypesTrue,
GlobOptionsWithFileTypesUnset,
} from './glob.js';
import { Glob } from './glob.js';
export { escape, unescape } from 'minimatch';
export type { FSOption, Path, WalkOptions, WalkOptionsWithFileTypesTrue, WalkOptionsWithFileTypesUnset, } from 'path-scurry';
export type {
FSOption,
Path,
WalkOptions,
WalkOptionsWithFileTypesTrue,
WalkOptionsWithFileTypesUnset,
} from 'path-scurry';
export { Glob } from './glob.js';
export type { GlobOptions, GlobOptionsWithFileTypesFalse, GlobOptionsWithFileTypesTrue, GlobOptionsWithFileTypesUnset, } from './glob.js';
export type {
GlobOptions,
GlobOptionsWithFileTypesFalse,
GlobOptionsWithFileTypesTrue,
GlobOptionsWithFileTypesUnset,
} from './glob.js';
export { hasMagic } from './has-magic.js';
export { Ignore } from './ignore.js';
export type { IgnoreLike } from './ignore.js';
@ -15,83 +31,165 @@ export type { MatchStream } from './walker.js';
* you consume them, even all in a single tick if you consume them immediately,
* but will still respond to backpressure if they're not consumed immediately.
*/
export declare function globStreamSync(pattern: string | string[], options: GlobOptionsWithFileTypesTrue): Minipass<Path, Path>;
export declare function globStreamSync(pattern: string | string[], options: GlobOptionsWithFileTypesFalse): Minipass<string, string>;
export declare function globStreamSync(pattern: string | string[], options: GlobOptionsWithFileTypesUnset): Minipass<string, string>;
export declare function globStreamSync(pattern: string | string[], options: GlobOptions): Minipass<Path, Path> | Minipass<string, string>;
export declare function globStreamSync(
pattern: string | string[],
options: GlobOptionsWithFileTypesTrue
): Minipass<Path, Path>;
export declare function globStreamSync(
pattern: string | string[],
options: GlobOptionsWithFileTypesFalse
): Minipass<string, string>;
export declare function globStreamSync(
pattern: string | string[],
options: GlobOptionsWithFileTypesUnset
): Minipass<string, string>;
export declare function globStreamSync(
pattern: string | string[],
options: GlobOptions
): Minipass<Path, Path> | Minipass<string, string>;
/**
* Return a stream that emits all the strings or `Path` objects and
* then emits `end` when completed.
*/
export declare function globStream(pattern: string | string[], options: GlobOptionsWithFileTypesFalse): Minipass<string, string>;
export declare function globStream(pattern: string | string[], options: GlobOptionsWithFileTypesTrue): Minipass<Path, Path>;
export declare function globStream(pattern: string | string[], options?: GlobOptionsWithFileTypesUnset | undefined): Minipass<string, string>;
export declare function globStream(pattern: string | string[], options: GlobOptions): Minipass<Path, Path> | Minipass<string, string>;
export declare function globStream(
pattern: string | string[],
options: GlobOptionsWithFileTypesFalse
): Minipass<string, string>;
export declare function globStream(
pattern: string | string[],
options: GlobOptionsWithFileTypesTrue
): Minipass<Path, Path>;
export declare function globStream(
pattern: string | string[],
options?: GlobOptionsWithFileTypesUnset | undefined
): Minipass<string, string>;
export declare function globStream(
pattern: string | string[],
options: GlobOptions
): Minipass<Path, Path> | Minipass<string, string>;
/**
* Synchronous form of {@link glob}
*/
export declare function globSync(pattern: string | string[], options: GlobOptionsWithFileTypesFalse): string[];
export declare function globSync(pattern: string | string[], options: GlobOptionsWithFileTypesTrue): Path[];
export declare function globSync(pattern: string | string[], options?: GlobOptionsWithFileTypesUnset | undefined): string[];
export declare function globSync(pattern: string | string[], options: GlobOptions): Path[] | string[];
export declare function globSync(
pattern: string | string[],
options: GlobOptionsWithFileTypesFalse
): string[];
export declare function globSync(
pattern: string | string[],
options: GlobOptionsWithFileTypesTrue
): Path[];
export declare function globSync(
pattern: string | string[],
options?: GlobOptionsWithFileTypesUnset | undefined
): string[];
export declare function globSync(
pattern: string | string[],
options: GlobOptions
): Path[] | string[];
/**
* Perform an asynchronous glob search for the pattern(s) specified. Returns
* [Path](https://isaacs.github.io/path-scurry/classes/PathBase) objects if the
* {@link withFileTypes} option is set to `true`. See {@link GlobOptions} for
* full option descriptions.
*/
declare function glob_(pattern: string | string[], options?: GlobOptionsWithFileTypesUnset | undefined): Promise<string[]>;
declare function glob_(pattern: string | string[], options: GlobOptionsWithFileTypesTrue): Promise<Path[]>;
declare function glob_(pattern: string | string[], options: GlobOptionsWithFileTypesFalse): Promise<string[]>;
declare function glob_(pattern: string | string[], options: GlobOptions): Promise<Path[] | string[]>;
declare function glob_(
pattern: string | string[],
options?: GlobOptionsWithFileTypesUnset | undefined
): Promise<string[]>;
declare function glob_(
pattern: string | string[],
options: GlobOptionsWithFileTypesTrue
): Promise<Path[]>;
declare function glob_(
pattern: string | string[],
options: GlobOptionsWithFileTypesFalse
): Promise<string[]>;
declare function glob_(
pattern: string | string[],
options: GlobOptions
): Promise<Path[] | string[]>;
/**
* Return a sync iterator for walking glob pattern matches.
*/
export declare function globIterateSync(pattern: string | string[], options?: GlobOptionsWithFileTypesUnset | undefined): Generator<string, void, void>;
export declare function globIterateSync(pattern: string | string[], options: GlobOptionsWithFileTypesTrue): Generator<Path, void, void>;
export declare function globIterateSync(pattern: string | string[], options: GlobOptionsWithFileTypesFalse): Generator<string, void, void>;
export declare function globIterateSync(pattern: string | string[], options: GlobOptions): Generator<Path, void, void> | Generator<string, void, void>;
export declare function globIterateSync(
pattern: string | string[],
options?: GlobOptionsWithFileTypesUnset | undefined
): Generator<string, void, void>;
export declare function globIterateSync(
pattern: string | string[],
options: GlobOptionsWithFileTypesTrue
): Generator<Path, void, void>;
export declare function globIterateSync(
pattern: string | string[],
options: GlobOptionsWithFileTypesFalse
): Generator<string, void, void>;
export declare function globIterateSync(
pattern: string | string[],
options: GlobOptions
): Generator<Path, void, void> | Generator<string, void, void>;
/**
* Return an async iterator for walking glob pattern matches.
*/
export declare function globIterate(pattern: string | string[], options?: GlobOptionsWithFileTypesUnset | undefined): AsyncGenerator<string, void, void>;
export declare function globIterate(pattern: string | string[], options: GlobOptionsWithFileTypesTrue): AsyncGenerator<Path, void, void>;
export declare function globIterate(pattern: string | string[], options: GlobOptionsWithFileTypesFalse): AsyncGenerator<string, void, void>;
export declare function globIterate(pattern: string | string[], options: GlobOptions): AsyncGenerator<Path, void, void> | AsyncGenerator<string, void, void>;
export declare function globIterate(
pattern: string | string[],
options?: GlobOptionsWithFileTypesUnset | undefined
): AsyncGenerator<string, void, void>;
export declare function globIterate(
pattern: string | string[],
options: GlobOptionsWithFileTypesTrue
): AsyncGenerator<Path, void, void>;
export declare function globIterate(
pattern: string | string[],
options: GlobOptionsWithFileTypesFalse
): AsyncGenerator<string, void, void>;
export declare function globIterate(
pattern: string | string[],
options: GlobOptions
): AsyncGenerator<Path, void, void> | AsyncGenerator<string, void, void>;
export declare const streamSync: typeof globStreamSync;
export declare const stream: typeof globStream & {
sync: typeof globStreamSync;
sync: typeof globStreamSync;
};
export declare const iterateSync: typeof globIterateSync;
export declare const iterate: typeof globIterate & {
sync: typeof globIterateSync;
sync: typeof globIterateSync;
};
export declare const sync: typeof globSync & {
stream: typeof globStreamSync;
iterate: typeof globIterateSync;
stream: typeof globStreamSync;
iterate: typeof globIterateSync;
};
export declare const glob: typeof glob_ & {
glob: typeof glob_;
globSync: typeof globSync;
sync: typeof globSync & {
stream: typeof globStreamSync;
iterate: typeof globIterateSync;
};
globStream: typeof globStream;
stream: typeof globStream & {
sync: typeof globStreamSync;
};
globStreamSync: typeof globStreamSync;
streamSync: typeof globStreamSync;
globIterate: typeof globIterate;
iterate: typeof globIterate & {
sync: typeof globIterateSync;
};
globIterateSync: typeof globIterateSync;
iterateSync: typeof globIterateSync;
Glob: typeof Glob;
hasMagic: (pattern: string | string[], options?: GlobOptions) => boolean;
escape: (s: string, { windowsPathsNoEscape, }?: Pick<import("minimatch").MinimatchOptions, "windowsPathsNoEscape">) => string;
unescape: (s: string, { windowsPathsNoEscape, }?: Pick<import("minimatch").MinimatchOptions, "windowsPathsNoEscape">) => string;
glob: typeof glob_;
globSync: typeof globSync;
sync: typeof globSync & {
stream: typeof globStreamSync;
iterate: typeof globIterateSync;
};
globStream: typeof globStream;
stream: typeof globStream & {
sync: typeof globStreamSync;
};
globStreamSync: typeof globStreamSync;
streamSync: typeof globStreamSync;
globIterate: typeof globIterate;
iterate: typeof globIterate & {
sync: typeof globIterateSync;
};
globIterateSync: typeof globIterateSync;
iterateSync: typeof globIterateSync;
Glob: typeof Glob;
hasMagic: (pattern: string | string[], options?: GlobOptions) => boolean;
escape: (
s: string,
{
windowsPathsNoEscape,
}?: Pick<import('minimatch').MinimatchOptions, 'windowsPathsNoEscape'>
) => string;
unescape: (
s: string,
{
windowsPathsNoEscape,
}?: Pick<import('minimatch').MinimatchOptions, 'windowsPathsNoEscape'>
) => string;
};
//# sourceMappingURL=index.d.ts.map
//# sourceMappingURL=index.d.ts.map

50
node_modules/glob/dist/esm/index.js generated vendored
View File

@ -6,50 +6,50 @@ export { Glob } from './glob.js';
export { hasMagic } from './has-magic.js';
export { Ignore } from './ignore.js';
export function globStreamSync(pattern, options = {}) {
return new Glob(pattern, options).streamSync();
return new Glob(pattern, options).streamSync();
}
export function globStream(pattern, options = {}) {
return new Glob(pattern, options).stream();
return new Glob(pattern, options).stream();
}
export function globSync(pattern, options = {}) {
return new Glob(pattern, options).walkSync();
return new Glob(pattern, options).walkSync();
}
async function glob_(pattern, options = {}) {
return new Glob(pattern, options).walk();
return new Glob(pattern, options).walk();
}
export function globIterateSync(pattern, options = {}) {
return new Glob(pattern, options).iterateSync();
return new Glob(pattern, options).iterateSync();
}
export function globIterate(pattern, options = {}) {
return new Glob(pattern, options).iterate();
return new Glob(pattern, options).iterate();
}
// aliases: glob.sync.stream() glob.stream.sync() glob.sync() etc
export const streamSync = globStreamSync;
export const stream = Object.assign(globStream, { sync: globStreamSync });
export const iterateSync = globIterateSync;
export const iterate = Object.assign(globIterate, {
sync: globIterateSync,
sync: globIterateSync,
});
export const sync = Object.assign(globSync, {
stream: globStreamSync,
iterate: globIterateSync,
stream: globStreamSync,
iterate: globIterateSync,
});
export const glob = Object.assign(glob_, {
glob: glob_,
globSync,
sync,
globStream,
stream,
globStreamSync,
streamSync,
globIterate,
iterate,
globIterateSync,
iterateSync,
Glob,
hasMagic,
escape,
unescape,
glob: glob_,
globSync,
sync,
globStream,
stream,
globStreamSync,
streamSync,
globIterate,
iterate,
globIterateSync,
iterateSync,
Glob,
hasMagic,
escape,
unescape,
});
glob.glob = glob;
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map

View File

@ -2,11 +2,11 @@ import { GLOBSTAR } from 'minimatch';
export type MMPattern = string | RegExp | typeof GLOBSTAR;
export type PatternList = [p: MMPattern, ...rest: MMPattern[]];
export type UNCPatternList = [
p0: '',
p1: '',
p2: string,
p3: string,
...rest: MMPattern[]
p0: '',
p1: '',
p2: string,
p3: string,
...rest: MMPattern[],
];
export type DrivePatternList = [p0: string, ...rest: MMPattern[]];
export type AbsolutePatternList = [p0: '', ...rest: MMPattern[]];
@ -16,61 +16,66 @@ export type GlobList = [p: string, ...rest: string[]];
* results
*/
export declare class Pattern {
#private;
readonly length: number;
constructor(patternList: MMPattern[], globList: string[], index: number, platform: NodeJS.Platform);
/**
* The first entry in the parsed list of patterns
*/
pattern(): MMPattern;
/**
* true of if pattern() returns a string
*/
isString(): boolean;
/**
* true of if pattern() returns GLOBSTAR
*/
isGlobstar(): boolean;
/**
* true if pattern() returns a regexp
*/
isRegExp(): boolean;
/**
* The /-joined set of glob parts that make up this pattern
*/
globString(): string;
/**
* true if there are more pattern parts after this one
*/
hasMore(): boolean;
/**
* The rest of the pattern after this part, or null if this is the end
*/
rest(): Pattern | null;
/**
* true if the pattern represents a //unc/path/ on windows
*/
isUNC(): boolean;
/**
* True if the pattern starts with a drive letter on Windows
*/
isDrive(): boolean;
/**
* True if the pattern is rooted on an absolute path
*/
isAbsolute(): boolean;
/**
* consume the root of the pattern, and return it
*/
root(): string;
/**
* Check to see if the current globstar pattern is allowed to follow
* a symbolic link.
*/
checkFollowGlobstar(): boolean;
/**
* Mark that the current globstar pattern is following a symbolic link
*/
markFollowGlobstar(): boolean;
#private;
readonly length: number;
constructor(
patternList: MMPattern[],
globList: string[],
index: number,
platform: NodeJS.Platform
);
/**
* The first entry in the parsed list of patterns
*/
pattern(): MMPattern;
/**
* true of if pattern() returns a string
*/
isString(): boolean;
/**
* true of if pattern() returns GLOBSTAR
*/
isGlobstar(): boolean;
/**
* true if pattern() returns a regexp
*/
isRegExp(): boolean;
/**
* The /-joined set of glob parts that make up this pattern
*/
globString(): string;
/**
* true if there are more pattern parts after this one
*/
hasMore(): boolean;
/**
* The rest of the pattern after this part, or null if this is the end
*/
rest(): Pattern | null;
/**
* true if the pattern represents a //unc/path/ on windows
*/
isUNC(): boolean;
/**
* True if the pattern starts with a drive letter on Windows
*/
isDrive(): boolean;
/**
* True if the pattern is rooted on an absolute path
*/
isAbsolute(): boolean;
/**
* consume the root of the pattern, and return it
*/
root(): string;
/**
* Check to see if the current globstar pattern is allowed to follow
* a symbolic link.
*/
checkFollowGlobstar(): boolean;
/**
* Mark that the current globstar pattern is following a symbolic link
*/
markFollowGlobstar(): boolean;
}
//# sourceMappingURL=pattern.d.ts.map
//# sourceMappingURL=pattern.d.ts.map

402
node_modules/glob/dist/esm/pattern.js generated vendored
View File

@ -7,209 +7,207 @@ const isGlobList = (gl) => gl.length >= 1;
* results
*/
export class Pattern {
#patternList;
#globList;
#index;
length;
#platform;
#rest;
#globString;
#isDrive;
#isUNC;
#isAbsolute;
#followGlobstar = true;
constructor(patternList, globList, index, platform) {
if (!isPatternList(patternList)) {
throw new TypeError('empty pattern list');
#patternList;
#globList;
#index;
length;
#platform;
#rest;
#globString;
#isDrive;
#isUNC;
#isAbsolute;
#followGlobstar = true;
constructor(patternList, globList, index, platform) {
if (!isPatternList(patternList)) {
throw new TypeError('empty pattern list');
}
if (!isGlobList(globList)) {
throw new TypeError('empty glob list');
}
if (globList.length !== patternList.length) {
throw new TypeError('mismatched pattern list and glob list lengths');
}
this.length = patternList.length;
if (index < 0 || index >= this.length) {
throw new TypeError('index out of range');
}
this.#patternList = patternList;
this.#globList = globList;
this.#index = index;
this.#platform = platform;
// normalize root entries of absolute patterns on initial creation.
if (this.#index === 0) {
// c: => ['c:/']
// C:/ => ['C:/']
// C:/x => ['C:/', 'x']
// //host/share => ['//host/share/']
// //host/share/ => ['//host/share/']
// //host/share/x => ['//host/share/', 'x']
// /etc => ['/', 'etc']
// / => ['/']
if (this.isUNC()) {
// '' / '' / 'host' / 'share'
const [p0, p1, p2, p3, ...prest] = this.#patternList;
const [g0, g1, g2, g3, ...grest] = this.#globList;
if (prest[0] === '') {
// ends in /
prest.shift();
grest.shift();
}
if (!isGlobList(globList)) {
throw new TypeError('empty glob list');
}
if (globList.length !== patternList.length) {
throw new TypeError('mismatched pattern list and glob list lengths');
}
this.length = patternList.length;
if (index < 0 || index >= this.length) {
throw new TypeError('index out of range');
}
this.#patternList = patternList;
this.#globList = globList;
this.#index = index;
this.#platform = platform;
// normalize root entries of absolute patterns on initial creation.
if (this.#index === 0) {
// c: => ['c:/']
// C:/ => ['C:/']
// C:/x => ['C:/', 'x']
// //host/share => ['//host/share/']
// //host/share/ => ['//host/share/']
// //host/share/x => ['//host/share/', 'x']
// /etc => ['/', 'etc']
// / => ['/']
if (this.isUNC()) {
// '' / '' / 'host' / 'share'
const [p0, p1, p2, p3, ...prest] = this.#patternList;
const [g0, g1, g2, g3, ...grest] = this.#globList;
if (prest[0] === '') {
// ends in /
prest.shift();
grest.shift();
}
const p = [p0, p1, p2, p3, ''].join('/');
const g = [g0, g1, g2, g3, ''].join('/');
this.#patternList = [p, ...prest];
this.#globList = [g, ...grest];
this.length = this.#patternList.length;
}
else if (this.isDrive() || this.isAbsolute()) {
const [p1, ...prest] = this.#patternList;
const [g1, ...grest] = this.#globList;
if (prest[0] === '') {
// ends in /
prest.shift();
grest.shift();
}
const p = p1 + '/';
const g = g1 + '/';
this.#patternList = [p, ...prest];
this.#globList = [g, ...grest];
this.length = this.#patternList.length;
}
const p = [p0, p1, p2, p3, ''].join('/');
const g = [g0, g1, g2, g3, ''].join('/');
this.#patternList = [p, ...prest];
this.#globList = [g, ...grest];
this.length = this.#patternList.length;
} else if (this.isDrive() || this.isAbsolute()) {
const [p1, ...prest] = this.#patternList;
const [g1, ...grest] = this.#globList;
if (prest[0] === '') {
// ends in /
prest.shift();
grest.shift();
}
const p = p1 + '/';
const g = g1 + '/';
this.#patternList = [p, ...prest];
this.#globList = [g, ...grest];
this.length = this.#patternList.length;
}
}
/**
* The first entry in the parsed list of patterns
*/
pattern() {
return this.#patternList[this.#index];
}
/**
* true of if pattern() returns a string
*/
isString() {
return typeof this.#patternList[this.#index] === 'string';
}
/**
* true of if pattern() returns GLOBSTAR
*/
isGlobstar() {
return this.#patternList[this.#index] === GLOBSTAR;
}
/**
* true if pattern() returns a regexp
*/
isRegExp() {
return this.#patternList[this.#index] instanceof RegExp;
}
/**
* The /-joined set of glob parts that make up this pattern
*/
globString() {
return (this.#globString =
this.#globString ||
(this.#index === 0 ?
this.isAbsolute() ?
this.#globList[0] + this.#globList.slice(1).join('/')
: this.#globList.join('/')
: this.#globList.slice(this.#index).join('/')));
}
/**
* true if there are more pattern parts after this one
*/
hasMore() {
return this.length > this.#index + 1;
}
/**
* The rest of the pattern after this part, or null if this is the end
*/
rest() {
if (this.#rest !== undefined)
return this.#rest;
if (!this.hasMore())
return (this.#rest = null);
this.#rest = new Pattern(this.#patternList, this.#globList, this.#index + 1, this.#platform);
this.#rest.#isAbsolute = this.#isAbsolute;
this.#rest.#isUNC = this.#isUNC;
this.#rest.#isDrive = this.#isDrive;
return this.#rest;
}
/**
* true if the pattern represents a //unc/path/ on windows
*/
isUNC() {
const pl = this.#patternList;
return this.#isUNC !== undefined ?
this.#isUNC
: (this.#isUNC =
this.#platform === 'win32' &&
this.#index === 0 &&
pl[0] === '' &&
pl[1] === '' &&
typeof pl[2] === 'string' &&
!!pl[2] &&
typeof pl[3] === 'string' &&
!!pl[3]);
}
// pattern like C:/...
// split = ['C:', ...]
// XXX: would be nice to handle patterns like `c:*` to test the cwd
// in c: for *, but I don't know of a way to even figure out what that
// cwd is without actually chdir'ing into it?
/**
* True if the pattern starts with a drive letter on Windows
*/
isDrive() {
const pl = this.#patternList;
return this.#isDrive !== undefined ?
this.#isDrive
: (this.#isDrive =
this.#platform === 'win32' &&
this.#index === 0 &&
this.length > 1 &&
typeof pl[0] === 'string' &&
/^[a-z]:$/i.test(pl[0]));
}
// pattern = '/' or '/...' or '/x/...'
// split = ['', ''] or ['', ...] or ['', 'x', ...]
// Drive and UNC both considered absolute on windows
/**
* True if the pattern is rooted on an absolute path
*/
isAbsolute() {
const pl = this.#patternList;
return this.#isAbsolute !== undefined ?
this.#isAbsolute
: (this.#isAbsolute =
(pl[0] === '' && pl.length > 1) ||
this.isDrive() ||
this.isUNC());
}
/**
* consume the root of the pattern, and return it
*/
root() {
const p = this.#patternList[0];
return (typeof p === 'string' && this.isAbsolute() && this.#index === 0) ?
p
: '';
}
/**
* Check to see if the current globstar pattern is allowed to follow
* a symbolic link.
*/
checkFollowGlobstar() {
return !(this.#index === 0 ||
!this.isGlobstar() ||
!this.#followGlobstar);
}
/**
* Mark that the current globstar pattern is following a symbolic link
*/
markFollowGlobstar() {
if (this.#index === 0 || !this.isGlobstar() || !this.#followGlobstar)
return false;
this.#followGlobstar = false;
return true;
}
}
/**
* The first entry in the parsed list of patterns
*/
pattern() {
return this.#patternList[this.#index];
}
/**
* true of if pattern() returns a string
*/
isString() {
return typeof this.#patternList[this.#index] === 'string';
}
/**
* true of if pattern() returns GLOBSTAR
*/
isGlobstar() {
return this.#patternList[this.#index] === GLOBSTAR;
}
/**
* true if pattern() returns a regexp
*/
isRegExp() {
return this.#patternList[this.#index] instanceof RegExp;
}
/**
* The /-joined set of glob parts that make up this pattern
*/
globString() {
return (this.#globString =
this.#globString ||
(this.#index === 0 ?
this.isAbsolute() ?
this.#globList[0] + this.#globList.slice(1).join('/')
: this.#globList.join('/')
: this.#globList.slice(this.#index).join('/')));
}
/**
* true if there are more pattern parts after this one
*/
hasMore() {
return this.length > this.#index + 1;
}
/**
* The rest of the pattern after this part, or null if this is the end
*/
rest() {
if (this.#rest !== undefined) return this.#rest;
if (!this.hasMore()) return (this.#rest = null);
this.#rest = new Pattern(
this.#patternList,
this.#globList,
this.#index + 1,
this.#platform
);
this.#rest.#isAbsolute = this.#isAbsolute;
this.#rest.#isUNC = this.#isUNC;
this.#rest.#isDrive = this.#isDrive;
return this.#rest;
}
/**
* true if the pattern represents a //unc/path/ on windows
*/
isUNC() {
const pl = this.#patternList;
return this.#isUNC !== undefined ?
this.#isUNC
: (this.#isUNC =
this.#platform === 'win32' &&
this.#index === 0 &&
pl[0] === '' &&
pl[1] === '' &&
typeof pl[2] === 'string' &&
!!pl[2] &&
typeof pl[3] === 'string' &&
!!pl[3]);
}
// pattern like C:/...
// split = ['C:', ...]
// XXX: would be nice to handle patterns like `c:*` to test the cwd
// in c: for *, but I don't know of a way to even figure out what that
// cwd is without actually chdir'ing into it?
/**
* True if the pattern starts with a drive letter on Windows
*/
isDrive() {
const pl = this.#patternList;
return this.#isDrive !== undefined ?
this.#isDrive
: (this.#isDrive =
this.#platform === 'win32' &&
this.#index === 0 &&
this.length > 1 &&
typeof pl[0] === 'string' &&
/^[a-z]:$/i.test(pl[0]));
}
// pattern = '/' or '/...' or '/x/...'
// split = ['', ''] or ['', ...] or ['', 'x', ...]
// Drive and UNC both considered absolute on windows
/**
* True if the pattern is rooted on an absolute path
*/
isAbsolute() {
const pl = this.#patternList;
return this.#isAbsolute !== undefined ?
this.#isAbsolute
: (this.#isAbsolute =
(pl[0] === '' && pl.length > 1) || this.isDrive() || this.isUNC());
}
/**
* consume the root of the pattern, and return it
*/
root() {
const p = this.#patternList[0];
return typeof p === 'string' && this.isAbsolute() && this.#index === 0 ?
p
: '';
}
/**
* Check to see if the current globstar pattern is allowed to follow
* a symbolic link.
*/
checkFollowGlobstar() {
return !(this.#index === 0 || !this.isGlobstar() || !this.#followGlobstar);
}
/**
* Mark that the current globstar pattern is following a symbolic link
*/
markFollowGlobstar() {
if (this.#index === 0 || !this.isGlobstar() || !this.#followGlobstar)
return false;
this.#followGlobstar = false;
return true;
}
}
//# sourceMappingURL=pattern.js.map
//# sourceMappingURL=pattern.js.map

View File

@ -6,11 +6,11 @@ import { GlobWalkerOpts } from './walker.js';
* A cache of which patterns have been processed for a given Path
*/
export declare class HasWalkedCache {
store: Map<string, Set<string>>;
constructor(store?: Map<string, Set<string>>);
copy(): HasWalkedCache;
hasWalked(target: Path, pattern: Pattern): boolean | undefined;
storeWalked(target: Path, pattern: Pattern): void;
store: Map<string, Set<string>>;
constructor(store?: Map<string, Set<string>>);
copy(): HasWalkedCache;
hasWalked(target: Path, pattern: Pattern): boolean | undefined;
storeWalked(target: Path, pattern: Pattern): void;
}
/**
* A record of which paths have been matched in a given walk step,
@ -18,20 +18,20 @@ export declare class HasWalkedCache {
* and whether their absolute or relative path should be returned.
*/
export declare class MatchRecord {
store: Map<Path, number>;
add(target: Path, absolute: boolean, ifDir: boolean): void;
entries(): [Path, boolean, boolean][];
store: Map<Path, number>;
add(target: Path, absolute: boolean, ifDir: boolean): void;
entries(): [Path, boolean, boolean][];
}
/**
* A collection of patterns that must be processed in a subsequent step
* for a given path.
*/
export declare class SubWalks {
store: Map<Path, Pattern[]>;
add(target: Path, pattern: Pattern): void;
get(target: Path): Pattern[];
entries(): [Path, Pattern[]][];
keys(): Path[];
store: Map<Path, Pattern[]>;
add(target: Path, pattern: Pattern): void;
get(target: Path): Pattern[];
entries(): [Path, Pattern[]][];
keys(): Path[];
}
/**
* The class that processes patterns for a given path.
@ -40,20 +40,30 @@ export declare class SubWalks {
* directory contents must be read.
*/
export declare class Processor {
hasWalkedCache: HasWalkedCache;
matches: MatchRecord;
subwalks: SubWalks;
patterns?: Pattern[];
follow: boolean;
dot: boolean;
opts: GlobWalkerOpts;
constructor(opts: GlobWalkerOpts, hasWalkedCache?: HasWalkedCache);
processPatterns(target: Path, patterns: Pattern[]): this;
subwalkTargets(): Path[];
child(): Processor;
filterEntries(parent: Path, entries: Path[]): Processor;
testGlobstar(e: Path, pattern: Pattern, rest: Pattern | null, absolute: boolean): void;
testRegExp(e: Path, p: MMRegExp, rest: Pattern | null, absolute: boolean): void;
testString(e: Path, p: string, rest: Pattern | null, absolute: boolean): void;
hasWalkedCache: HasWalkedCache;
matches: MatchRecord;
subwalks: SubWalks;
patterns?: Pattern[];
follow: boolean;
dot: boolean;
opts: GlobWalkerOpts;
constructor(opts: GlobWalkerOpts, hasWalkedCache?: HasWalkedCache);
processPatterns(target: Path, patterns: Pattern[]): this;
subwalkTargets(): Path[];
child(): Processor;
filterEntries(parent: Path, entries: Path[]): Processor;
testGlobstar(
e: Path,
pattern: Pattern,
rest: Pattern | null,
absolute: boolean
): void;
testRegExp(
e: Path,
p: MMRegExp,
rest: Pattern | null,
absolute: boolean
): void;
testString(e: Path, p: string, rest: Pattern | null, absolute: boolean): void;
}
//# sourceMappingURL=processor.d.ts.map
//# sourceMappingURL=processor.d.ts.map

View File

@ -4,24 +4,22 @@ import { GLOBSTAR } from 'minimatch';
* A cache of which patterns have been processed for a given Path
*/
export class HasWalkedCache {
store;
constructor(store = new Map()) {
this.store = store;
}
copy() {
return new HasWalkedCache(new Map(this.store));
}
hasWalked(target, pattern) {
return this.store.get(target.fullpath())?.has(pattern.globString());
}
storeWalked(target, pattern) {
const fullpath = target.fullpath();
const cached = this.store.get(fullpath);
if (cached)
cached.add(pattern.globString());
else
this.store.set(fullpath, new Set([pattern.globString()]));
}
store;
constructor(store = new Map()) {
this.store = store;
}
copy() {
return new HasWalkedCache(new Map(this.store));
}
hasWalked(target, pattern) {
return this.store.get(target.fullpath())?.has(pattern.globString());
}
storeWalked(target, pattern) {
const fullpath = target.fullpath();
const cached = this.store.get(fullpath);
if (cached) cached.add(pattern.globString());
else this.store.set(fullpath, new Set([pattern.globString()]));
}
}
/**
* A record of which paths have been matched in a given walk step,
@ -29,55 +27,53 @@ export class HasWalkedCache {
* and whether their absolute or relative path should be returned.
*/
export class MatchRecord {
store = new Map();
add(target, absolute, ifDir) {
const n = (absolute ? 2 : 0) | (ifDir ? 1 : 0);
const current = this.store.get(target);
this.store.set(target, current === undefined ? n : n & current);
}
// match, absolute, ifdir
entries() {
return [...this.store.entries()].map(([path, n]) => [
path,
!!(n & 2),
!!(n & 1),
]);
}
store = new Map();
add(target, absolute, ifDir) {
const n = (absolute ? 2 : 0) | (ifDir ? 1 : 0);
const current = this.store.get(target);
this.store.set(target, current === undefined ? n : n & current);
}
// match, absolute, ifdir
entries() {
return [...this.store.entries()].map(([path, n]) => [
path,
!!(n & 2),
!!(n & 1),
]);
}
}
/**
* A collection of patterns that must be processed in a subsequent step
* for a given path.
*/
export class SubWalks {
store = new Map();
add(target, pattern) {
if (!target.canReaddir()) {
return;
}
const subs = this.store.get(target);
if (subs) {
if (!subs.find(p => p.globString() === pattern.globString())) {
subs.push(pattern);
}
}
else
this.store.set(target, [pattern]);
store = new Map();
add(target, pattern) {
if (!target.canReaddir()) {
return;
}
get(target) {
const subs = this.store.get(target);
/* c8 ignore start */
if (!subs) {
throw new Error('attempting to walk unknown path');
}
/* c8 ignore stop */
return subs;
}
entries() {
return this.keys().map(k => [k, this.store.get(k)]);
}
keys() {
return [...this.store.keys()].filter(t => t.canReaddir());
const subs = this.store.get(target);
if (subs) {
if (!subs.find((p) => p.globString() === pattern.globString())) {
subs.push(pattern);
}
} else this.store.set(target, [pattern]);
}
get(target) {
const subs = this.store.get(target);
/* c8 ignore start */
if (!subs) {
throw new Error('attempting to walk unknown path');
}
/* c8 ignore stop */
return subs;
}
entries() {
return this.keys().map((k) => [k, this.store.get(k)]);
}
keys() {
return [...this.store.keys()].filter((t) => t.canReaddir());
}
}
/**
* The class that processes patterns for a given path.
@ -86,209 +82,198 @@ export class SubWalks {
* directory contents must be read.
*/
export class Processor {
hasWalkedCache;
matches = new MatchRecord();
subwalks = new SubWalks();
patterns;
follow;
dot;
opts;
constructor(opts, hasWalkedCache) {
this.opts = opts;
this.follow = !!opts.follow;
this.dot = !!opts.dot;
this.hasWalkedCache =
hasWalkedCache ? hasWalkedCache.copy() : new HasWalkedCache();
}
processPatterns(target, patterns) {
this.patterns = patterns;
const processingSet = patterns.map(p => [target, p]);
// map of paths to the magic-starting subwalks they need to walk
// first item in patterns is the filter
for (let [t, pattern] of processingSet) {
this.hasWalkedCache.storeWalked(t, pattern);
const root = pattern.root();
const absolute = pattern.isAbsolute() && this.opts.absolute !== false;
// start absolute patterns at root
if (root) {
t = t.resolve(root === '/' && this.opts.root !== undefined ?
this.opts.root
: root);
const rest = pattern.rest();
if (!rest) {
this.matches.add(t, true, false);
continue;
}
else {
pattern = rest;
}
}
if (t.isENOENT())
continue;
let p;
let rest;
let changed = false;
while (typeof (p = pattern.pattern()) === 'string' &&
(rest = pattern.rest())) {
const c = t.resolve(p);
t = c;
pattern = rest;
changed = true;
}
p = pattern.pattern();
rest = pattern.rest();
if (changed) {
if (this.hasWalkedCache.hasWalked(t, pattern))
continue;
this.hasWalkedCache.storeWalked(t, pattern);
}
// now we have either a final string for a known entry,
// more strings for an unknown entry,
// or a pattern starting with magic, mounted on t.
if (typeof p === 'string') {
// must not be final entry, otherwise we would have
// concatenated it earlier.
const ifDir = p === '..' || p === '' || p === '.';
this.matches.add(t.resolve(p), absolute, ifDir);
continue;
}
else if (p === GLOBSTAR) {
// if no rest, match and subwalk pattern
// if rest, process rest and subwalk pattern
// if it's a symlink, but we didn't get here by way of a
// globstar match (meaning it's the first time THIS globstar
// has traversed a symlink), then we follow it. Otherwise, stop.
if (!t.isSymbolicLink() ||
this.follow ||
pattern.checkFollowGlobstar()) {
this.subwalks.add(t, pattern);
}
const rp = rest?.pattern();
const rrest = rest?.rest();
if (!rest || ((rp === '' || rp === '.') && !rrest)) {
// only HAS to be a dir if it ends in **/ or **/.
// but ending in ** will match files as well.
this.matches.add(t, absolute, rp === '' || rp === '.');
}
else {
if (rp === '..') {
// this would mean you're matching **/.. at the fs root,
// and no thanks, I'm not gonna test that specific case.
/* c8 ignore start */
const tp = t.parent || t;
/* c8 ignore stop */
if (!rrest)
this.matches.add(tp, absolute, true);
else if (!this.hasWalkedCache.hasWalked(tp, rrest)) {
this.subwalks.add(tp, rrest);
}
}
}
}
else if (p instanceof RegExp) {
this.subwalks.add(t, pattern);
}
}
return this;
}
subwalkTargets() {
return this.subwalks.keys();
}
child() {
return new Processor(this.opts, this.hasWalkedCache);
}
// return a new Processor containing the subwalks for each
// child entry, and a set of matches, and
// a hasWalkedCache that's a copy of this one
// then we're going to call
filterEntries(parent, entries) {
const patterns = this.subwalks.get(parent);
// put matches and entry walks into the results processor
const results = this.child();
for (const e of entries) {
for (const pattern of patterns) {
const absolute = pattern.isAbsolute();
const p = pattern.pattern();
const rest = pattern.rest();
if (p === GLOBSTAR) {
results.testGlobstar(e, pattern, rest, absolute);
}
else if (p instanceof RegExp) {
results.testRegExp(e, p, rest, absolute);
}
else {
results.testString(e, p, rest, absolute);
}
}
}
return results;
}
testGlobstar(e, pattern, rest, absolute) {
if (this.dot || !e.name.startsWith('.')) {
if (!pattern.hasMore()) {
this.matches.add(e, absolute, false);
}
if (e.canReaddir()) {
// if we're in follow mode or it's not a symlink, just keep
// testing the same pattern. If there's more after the globstar,
// then this symlink consumes the globstar. If not, then we can
// follow at most ONE symlink along the way, so we mark it, which
// also checks to ensure that it wasn't already marked.
if (this.follow || !e.isSymbolicLink()) {
this.subwalks.add(e, pattern);
}
else if (e.isSymbolicLink()) {
if (rest && pattern.checkFollowGlobstar()) {
this.subwalks.add(e, rest);
}
else if (pattern.markFollowGlobstar()) {
this.subwalks.add(e, pattern);
}
}
}
}
// if the NEXT thing matches this entry, then also add
// the rest.
if (rest) {
const rp = rest.pattern();
if (typeof rp === 'string' &&
// dots and empty were handled already
rp !== '..' &&
rp !== '' &&
rp !== '.') {
this.testString(e, rp, rest.rest(), absolute);
}
else if (rp === '..') {
/* c8 ignore start */
const ep = e.parent || e;
/* c8 ignore stop */
this.subwalks.add(ep, rest);
}
else if (rp instanceof RegExp) {
this.testRegExp(e, rp, rest.rest(), absolute);
}
}
}
testRegExp(e, p, rest, absolute) {
if (!p.test(e.name))
return;
hasWalkedCache;
matches = new MatchRecord();
subwalks = new SubWalks();
patterns;
follow;
dot;
opts;
constructor(opts, hasWalkedCache) {
this.opts = opts;
this.follow = !!opts.follow;
this.dot = !!opts.dot;
this.hasWalkedCache =
hasWalkedCache ? hasWalkedCache.copy() : new HasWalkedCache();
}
processPatterns(target, patterns) {
this.patterns = patterns;
const processingSet = patterns.map((p) => [target, p]);
// map of paths to the magic-starting subwalks they need to walk
// first item in patterns is the filter
for (let [t, pattern] of processingSet) {
this.hasWalkedCache.storeWalked(t, pattern);
const root = pattern.root();
const absolute = pattern.isAbsolute() && this.opts.absolute !== false;
// start absolute patterns at root
if (root) {
t = t.resolve(
root === '/' && this.opts.root !== undefined ? this.opts.root : root
);
const rest = pattern.rest();
if (!rest) {
this.matches.add(e, absolute, false);
this.matches.add(t, true, false);
continue;
} else {
pattern = rest;
}
else {
this.subwalks.add(e, rest);
}
if (t.isENOENT()) continue;
let p;
let rest;
let changed = false;
while (
typeof (p = pattern.pattern()) === 'string' &&
(rest = pattern.rest())
) {
const c = t.resolve(p);
t = c;
pattern = rest;
changed = true;
}
p = pattern.pattern();
rest = pattern.rest();
if (changed) {
if (this.hasWalkedCache.hasWalked(t, pattern)) continue;
this.hasWalkedCache.storeWalked(t, pattern);
}
// now we have either a final string for a known entry,
// more strings for an unknown entry,
// or a pattern starting with magic, mounted on t.
if (typeof p === 'string') {
// must not be final entry, otherwise we would have
// concatenated it earlier.
const ifDir = p === '..' || p === '' || p === '.';
this.matches.add(t.resolve(p), absolute, ifDir);
continue;
} else if (p === GLOBSTAR) {
// if no rest, match and subwalk pattern
// if rest, process rest and subwalk pattern
// if it's a symlink, but we didn't get here by way of a
// globstar match (meaning it's the first time THIS globstar
// has traversed a symlink), then we follow it. Otherwise, stop.
if (
!t.isSymbolicLink() ||
this.follow ||
pattern.checkFollowGlobstar()
) {
this.subwalks.add(t, pattern);
}
const rp = rest?.pattern();
const rrest = rest?.rest();
if (!rest || ((rp === '' || rp === '.') && !rrest)) {
// only HAS to be a dir if it ends in **/ or **/.
// but ending in ** will match files as well.
this.matches.add(t, absolute, rp === '' || rp === '.');
} else {
if (rp === '..') {
// this would mean you're matching **/.. at the fs root,
// and no thanks, I'm not gonna test that specific case.
/* c8 ignore start */
const tp = t.parent || t;
/* c8 ignore stop */
if (!rrest) this.matches.add(tp, absolute, true);
else if (!this.hasWalkedCache.hasWalked(tp, rrest)) {
this.subwalks.add(tp, rrest);
}
}
}
} else if (p instanceof RegExp) {
this.subwalks.add(t, pattern);
}
}
testString(e, p, rest, absolute) {
// should never happen?
if (!e.isNamed(p))
return;
if (!rest) {
this.matches.add(e, absolute, false);
}
else {
this.subwalks.add(e, rest);
return this;
}
subwalkTargets() {
return this.subwalks.keys();
}
child() {
return new Processor(this.opts, this.hasWalkedCache);
}
// return a new Processor containing the subwalks for each
// child entry, and a set of matches, and
// a hasWalkedCache that's a copy of this one
// then we're going to call
filterEntries(parent, entries) {
const patterns = this.subwalks.get(parent);
// put matches and entry walks into the results processor
const results = this.child();
for (const e of entries) {
for (const pattern of patterns) {
const absolute = pattern.isAbsolute();
const p = pattern.pattern();
const rest = pattern.rest();
if (p === GLOBSTAR) {
results.testGlobstar(e, pattern, rest, absolute);
} else if (p instanceof RegExp) {
results.testRegExp(e, p, rest, absolute);
} else {
results.testString(e, p, rest, absolute);
}
}
}
return results;
}
testGlobstar(e, pattern, rest, absolute) {
if (this.dot || !e.name.startsWith('.')) {
if (!pattern.hasMore()) {
this.matches.add(e, absolute, false);
}
if (e.canReaddir()) {
// if we're in follow mode or it's not a symlink, just keep
// testing the same pattern. If there's more after the globstar,
// then this symlink consumes the globstar. If not, then we can
// follow at most ONE symlink along the way, so we mark it, which
// also checks to ensure that it wasn't already marked.
if (this.follow || !e.isSymbolicLink()) {
this.subwalks.add(e, pattern);
} else if (e.isSymbolicLink()) {
if (rest && pattern.checkFollowGlobstar()) {
this.subwalks.add(e, rest);
} else if (pattern.markFollowGlobstar()) {
this.subwalks.add(e, pattern);
}
}
}
}
// if the NEXT thing matches this entry, then also add
// the rest.
if (rest) {
const rp = rest.pattern();
if (
typeof rp === 'string' &&
// dots and empty were handled already
rp !== '..' &&
rp !== '' &&
rp !== '.'
) {
this.testString(e, rp, rest.rest(), absolute);
} else if (rp === '..') {
/* c8 ignore start */
const ep = e.parent || e;
/* c8 ignore stop */
this.subwalks.add(ep, rest);
} else if (rp instanceof RegExp) {
this.testRegExp(e, rp, rest.rest(), absolute);
}
}
}
testRegExp(e, p, rest, absolute) {
if (!p.test(e.name)) return;
if (!rest) {
this.matches.add(e, absolute, false);
} else {
this.subwalks.add(e, rest);
}
}
testString(e, p, rest, absolute) {
// should never happen?
if (!e.isNamed(p)) return;
if (!rest) {
this.matches.add(e, absolute, false);
} else {
this.subwalks.add(e, rest);
}
}
}
//# sourceMappingURL=processor.js.map
//# sourceMappingURL=processor.js.map

View File

@ -10,88 +10,125 @@ import { IgnoreLike } from './ignore.js';
import { Pattern } from './pattern.js';
import { Processor } from './processor.js';
export interface GlobWalkerOpts {
absolute?: boolean;
allowWindowsEscape?: boolean;
cwd?: string | URL;
dot?: boolean;
dotRelative?: boolean;
follow?: boolean;
ignore?: string | string[] | IgnoreLike;
mark?: boolean;
matchBase?: boolean;
maxDepth?: number;
nobrace?: boolean;
nocase?: boolean;
nodir?: boolean;
noext?: boolean;
noglobstar?: boolean;
platform?: NodeJS.Platform;
posix?: boolean;
realpath?: boolean;
root?: string;
stat?: boolean;
signal?: AbortSignal;
windowsPathsNoEscape?: boolean;
withFileTypes?: boolean;
includeChildMatches?: boolean;
absolute?: boolean;
allowWindowsEscape?: boolean;
cwd?: string | URL;
dot?: boolean;
dotRelative?: boolean;
follow?: boolean;
ignore?: string | string[] | IgnoreLike;
mark?: boolean;
matchBase?: boolean;
maxDepth?: number;
nobrace?: boolean;
nocase?: boolean;
nodir?: boolean;
noext?: boolean;
noglobstar?: boolean;
platform?: NodeJS.Platform;
posix?: boolean;
realpath?: boolean;
root?: string;
stat?: boolean;
signal?: AbortSignal;
windowsPathsNoEscape?: boolean;
withFileTypes?: boolean;
includeChildMatches?: boolean;
}
export type GWOFileTypesTrue = GlobWalkerOpts & {
withFileTypes: true;
withFileTypes: true;
};
export type GWOFileTypesFalse = GlobWalkerOpts & {
withFileTypes: false;
withFileTypes: false;
};
export type GWOFileTypesUnset = GlobWalkerOpts & {
withFileTypes?: undefined;
withFileTypes?: undefined;
};
export type Result<O extends GlobWalkerOpts> = O extends GWOFileTypesTrue ? Path : O extends GWOFileTypesFalse ? string : O extends GWOFileTypesUnset ? string : Path | string;
export type Matches<O extends GlobWalkerOpts> = O extends GWOFileTypesTrue ? Set<Path> : O extends GWOFileTypesFalse ? Set<string> : O extends GWOFileTypesUnset ? Set<string> : Set<Path | string>;
export type MatchStream<O extends GlobWalkerOpts> = Minipass<Result<O>, Result<O>>;
export type Result<O extends GlobWalkerOpts> =
O extends GWOFileTypesTrue ? Path
: O extends GWOFileTypesFalse ? string
: O extends GWOFileTypesUnset ? string
: Path | string;
export type Matches<O extends GlobWalkerOpts> =
O extends GWOFileTypesTrue ? Set<Path>
: O extends GWOFileTypesFalse ? Set<string>
: O extends GWOFileTypesUnset ? Set<string>
: Set<Path | string>;
export type MatchStream<O extends GlobWalkerOpts> = Minipass<
Result<O>,
Result<O>
>;
/**
* basic walking utilities that all the glob walker types use
*/
export declare abstract class GlobUtil<O extends GlobWalkerOpts = GlobWalkerOpts> {
#private;
path: Path;
patterns: Pattern[];
opts: O;
seen: Set<Path>;
paused: boolean;
aborted: boolean;
signal?: AbortSignal;
maxDepth: number;
includeChildMatches: boolean;
constructor(patterns: Pattern[], path: Path, opts: O);
pause(): void;
resume(): void;
onResume(fn: () => any): void;
matchCheck(e: Path, ifDir: boolean): Promise<Path | undefined>;
matchCheckTest(e: Path | undefined, ifDir: boolean): Path | undefined;
matchCheckSync(e: Path, ifDir: boolean): Path | undefined;
abstract matchEmit(p: Result<O>): void;
abstract matchEmit(p: string | Path): void;
matchFinish(e: Path, absolute: boolean): void;
match(e: Path, absolute: boolean, ifDir: boolean): Promise<void>;
matchSync(e: Path, absolute: boolean, ifDir: boolean): void;
walkCB(target: Path, patterns: Pattern[], cb: () => any): void;
walkCB2(target: Path, patterns: Pattern[], processor: Processor, cb: () => any): any;
walkCB3(target: Path, entries: Path[], processor: Processor, cb: () => any): void;
walkCBSync(target: Path, patterns: Pattern[], cb: () => any): void;
walkCB2Sync(target: Path, patterns: Pattern[], processor: Processor, cb: () => any): any;
walkCB3Sync(target: Path, entries: Path[], processor: Processor, cb: () => any): void;
export declare abstract class GlobUtil<
O extends GlobWalkerOpts = GlobWalkerOpts,
> {
#private;
path: Path;
patterns: Pattern[];
opts: O;
seen: Set<Path>;
paused: boolean;
aborted: boolean;
signal?: AbortSignal;
maxDepth: number;
includeChildMatches: boolean;
constructor(patterns: Pattern[], path: Path, opts: O);
pause(): void;
resume(): void;
onResume(fn: () => any): void;
matchCheck(e: Path, ifDir: boolean): Promise<Path | undefined>;
matchCheckTest(e: Path | undefined, ifDir: boolean): Path | undefined;
matchCheckSync(e: Path, ifDir: boolean): Path | undefined;
abstract matchEmit(p: Result<O>): void;
abstract matchEmit(p: string | Path): void;
matchFinish(e: Path, absolute: boolean): void;
match(e: Path, absolute: boolean, ifDir: boolean): Promise<void>;
matchSync(e: Path, absolute: boolean, ifDir: boolean): void;
walkCB(target: Path, patterns: Pattern[], cb: () => any): void;
walkCB2(
target: Path,
patterns: Pattern[],
processor: Processor,
cb: () => any
): any;
walkCB3(
target: Path,
entries: Path[],
processor: Processor,
cb: () => any
): void;
walkCBSync(target: Path, patterns: Pattern[], cb: () => any): void;
walkCB2Sync(
target: Path,
patterns: Pattern[],
processor: Processor,
cb: () => any
): any;
walkCB3Sync(
target: Path,
entries: Path[],
processor: Processor,
cb: () => any
): void;
}
export declare class GlobWalker<O extends GlobWalkerOpts = GlobWalkerOpts> extends GlobUtil<O> {
matches: Set<Result<O>>;
constructor(patterns: Pattern[], path: Path, opts: O);
matchEmit(e: Result<O>): void;
walk(): Promise<Set<Result<O>>>;
walkSync(): Set<Result<O>>;
export declare class GlobWalker<
O extends GlobWalkerOpts = GlobWalkerOpts,
> extends GlobUtil<O> {
matches: Set<Result<O>>;
constructor(patterns: Pattern[], path: Path, opts: O);
matchEmit(e: Result<O>): void;
walk(): Promise<Set<Result<O>>>;
walkSync(): Set<Result<O>>;
}
export declare class GlobStream<O extends GlobWalkerOpts = GlobWalkerOpts> extends GlobUtil<O> {
results: Minipass<Result<O>, Result<O>>;
constructor(patterns: Pattern[], path: Path, opts: O);
matchEmit(e: Result<O>): void;
stream(): MatchStream<O>;
streamSync(): MatchStream<O>;
export declare class GlobStream<
O extends GlobWalkerOpts = GlobWalkerOpts,
> extends GlobUtil<O> {
results: Minipass<Result<O>, Result<O>>;
constructor(patterns: Pattern[], path: Path, opts: O);
matchEmit(e: Result<O>): void;
stream(): MatchStream<O>;
streamSync(): MatchStream<O>;
}
//# sourceMappingURL=walker.d.ts.map
//# sourceMappingURL=walker.d.ts.map

654
node_modules/glob/dist/esm/walker.js generated vendored
View File

@ -7,375 +7,349 @@
import { Minipass } from 'minipass';
import { Ignore } from './ignore.js';
import { Processor } from './processor.js';
const makeIgnore = (ignore, opts) => typeof ignore === 'string' ? new Ignore([ignore], opts)
: Array.isArray(ignore) ? new Ignore(ignore, opts)
: ignore;
const makeIgnore = (ignore, opts) =>
typeof ignore === 'string' ? new Ignore([ignore], opts)
: Array.isArray(ignore) ? new Ignore(ignore, opts)
: ignore;
/**
* basic walking utilities that all the glob walker types use
*/
export class GlobUtil {
path;
patterns;
opts;
seen = new Set();
paused = false;
aborted = false;
#onResume = [];
#ignore;
#sep;
signal;
maxDepth;
includeChildMatches;
constructor(patterns, path, opts) {
this.patterns = patterns;
this.path = path;
this.opts = opts;
this.#sep = !opts.posix && opts.platform === 'win32' ? '\\' : '/';
this.includeChildMatches = opts.includeChildMatches !== false;
if (opts.ignore || !this.includeChildMatches) {
this.#ignore = makeIgnore(opts.ignore ?? [], opts);
if (!this.includeChildMatches &&
typeof this.#ignore.add !== 'function') {
const m = 'cannot ignore child matches, ignore lacks add() method.';
throw new Error(m);
}
}
// ignore, always set with maxDepth, but it's optional on the
// GlobOptions type
/* c8 ignore start */
this.maxDepth = opts.maxDepth || Infinity;
/* c8 ignore stop */
if (opts.signal) {
this.signal = opts.signal;
this.signal.addEventListener('abort', () => {
this.#onResume.length = 0;
});
}
path;
patterns;
opts;
seen = new Set();
paused = false;
aborted = false;
#onResume = [];
#ignore;
#sep;
signal;
maxDepth;
includeChildMatches;
constructor(patterns, path, opts) {
this.patterns = patterns;
this.path = path;
this.opts = opts;
this.#sep = !opts.posix && opts.platform === 'win32' ? '\\' : '/';
this.includeChildMatches = opts.includeChildMatches !== false;
if (opts.ignore || !this.includeChildMatches) {
this.#ignore = makeIgnore(opts.ignore ?? [], opts);
if (!this.includeChildMatches && typeof this.#ignore.add !== 'function') {
const m = 'cannot ignore child matches, ignore lacks add() method.';
throw new Error(m);
}
}
#ignored(path) {
return this.seen.has(path) || !!this.#ignore?.ignored?.(path);
// ignore, always set with maxDepth, but it's optional on the
// GlobOptions type
/* c8 ignore start */
this.maxDepth = opts.maxDepth || Infinity;
/* c8 ignore stop */
if (opts.signal) {
this.signal = opts.signal;
this.signal.addEventListener('abort', () => {
this.#onResume.length = 0;
});
}
#childrenIgnored(path) {
return !!this.#ignore?.childrenIgnored?.(path);
}
#ignored(path) {
return this.seen.has(path) || !!this.#ignore?.ignored?.(path);
}
#childrenIgnored(path) {
return !!this.#ignore?.childrenIgnored?.(path);
}
// backpressure mechanism
pause() {
this.paused = true;
}
resume() {
/* c8 ignore start */
if (this.signal?.aborted) return;
/* c8 ignore stop */
this.paused = false;
let fn = undefined;
while (!this.paused && (fn = this.#onResume.shift())) {
fn();
}
// backpressure mechanism
pause() {
this.paused = true;
}
onResume(fn) {
if (this.signal?.aborted) return;
/* c8 ignore start */
if (!this.paused) {
fn();
} else {
/* c8 ignore stop */
this.#onResume.push(fn);
}
resume() {
/* c8 ignore start */
if (this.signal?.aborted)
return;
/* c8 ignore stop */
this.paused = false;
let fn = undefined;
while (!this.paused && (fn = this.#onResume.shift())) {
fn();
}
}
// do the requisite realpath/stat checking, and return the path
// to add or undefined to filter it out.
async matchCheck(e, ifDir) {
if (ifDir && this.opts.nodir) return undefined;
let rpc;
if (this.opts.realpath) {
rpc = e.realpathCached() || (await e.realpath());
if (!rpc) return undefined;
e = rpc;
}
onResume(fn) {
if (this.signal?.aborted)
return;
/* c8 ignore start */
if (!this.paused) {
fn();
}
else {
/* c8 ignore stop */
this.#onResume.push(fn);
}
const needStat = e.isUnknown() || this.opts.stat;
const s = needStat ? await e.lstat() : e;
if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
const target = await s.realpath();
/* c8 ignore start */
if (target && (target.isUnknown() || this.opts.stat)) {
await target.lstat();
}
/* c8 ignore stop */
}
// do the requisite realpath/stat checking, and return the path
// to add or undefined to filter it out.
async matchCheck(e, ifDir) {
if (ifDir && this.opts.nodir)
return undefined;
let rpc;
if (this.opts.realpath) {
rpc = e.realpathCached() || (await e.realpath());
if (!rpc)
return undefined;
e = rpc;
}
const needStat = e.isUnknown() || this.opts.stat;
const s = needStat ? await e.lstat() : e;
if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
const target = await s.realpath();
/* c8 ignore start */
if (target && (target.isUnknown() || this.opts.stat)) {
await target.lstat();
}
/* c8 ignore stop */
}
return this.matchCheckTest(s, ifDir);
return this.matchCheckTest(s, ifDir);
}
matchCheckTest(e, ifDir) {
return (
e &&
(this.maxDepth === Infinity || e.depth() <= this.maxDepth) &&
(!ifDir || e.canReaddir()) &&
(!this.opts.nodir || !e.isDirectory()) &&
(!this.opts.nodir ||
!this.opts.follow ||
!e.isSymbolicLink() ||
!e.realpathCached()?.isDirectory()) &&
!this.#ignored(e)
) ?
e
: undefined;
}
matchCheckSync(e, ifDir) {
if (ifDir && this.opts.nodir) return undefined;
let rpc;
if (this.opts.realpath) {
rpc = e.realpathCached() || e.realpathSync();
if (!rpc) return undefined;
e = rpc;
}
matchCheckTest(e, ifDir) {
return (e &&
(this.maxDepth === Infinity || e.depth() <= this.maxDepth) &&
(!ifDir || e.canReaddir()) &&
(!this.opts.nodir || !e.isDirectory()) &&
(!this.opts.nodir ||
!this.opts.follow ||
!e.isSymbolicLink() ||
!e.realpathCached()?.isDirectory()) &&
!this.#ignored(e)) ?
e
: undefined;
const needStat = e.isUnknown() || this.opts.stat;
const s = needStat ? e.lstatSync() : e;
if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
const target = s.realpathSync();
if (target && (target?.isUnknown() || this.opts.stat)) {
target.lstatSync();
}
}
matchCheckSync(e, ifDir) {
if (ifDir && this.opts.nodir)
return undefined;
let rpc;
if (this.opts.realpath) {
rpc = e.realpathCached() || e.realpathSync();
if (!rpc)
return undefined;
e = rpc;
}
const needStat = e.isUnknown() || this.opts.stat;
const s = needStat ? e.lstatSync() : e;
if (this.opts.follow && this.opts.nodir && s?.isSymbolicLink()) {
const target = s.realpathSync();
if (target && (target?.isUnknown() || this.opts.stat)) {
target.lstatSync();
}
}
return this.matchCheckTest(s, ifDir);
return this.matchCheckTest(s, ifDir);
}
matchFinish(e, absolute) {
if (this.#ignored(e)) return;
// we know we have an ignore if this is false, but TS doesn't
if (!this.includeChildMatches && this.#ignore?.add) {
const ign = `${e.relativePosix()}/**`;
this.#ignore.add(ign);
}
matchFinish(e, absolute) {
if (this.#ignored(e))
return;
// we know we have an ignore if this is false, but TS doesn't
if (!this.includeChildMatches && this.#ignore?.add) {
const ign = `${e.relativePosix()}/**`;
this.#ignore.add(ign);
}
const abs = this.opts.absolute === undefined ? absolute : this.opts.absolute;
this.seen.add(e);
const mark = this.opts.mark && e.isDirectory() ? this.#sep : '';
// ok, we have what we need!
if (this.opts.withFileTypes) {
this.matchEmit(e);
}
else if (abs) {
const abs = this.opts.posix ? e.fullpathPosix() : e.fullpath();
this.matchEmit(abs + mark);
}
else {
const rel = this.opts.posix ? e.relativePosix() : e.relative();
const pre = this.opts.dotRelative && !rel.startsWith('..' + this.#sep) ?
'.' + this.#sep
: '';
this.matchEmit(!rel ? '.' + mark : pre + rel + mark);
}
const abs =
this.opts.absolute === undefined ? absolute : this.opts.absolute;
this.seen.add(e);
const mark = this.opts.mark && e.isDirectory() ? this.#sep : '';
// ok, we have what we need!
if (this.opts.withFileTypes) {
this.matchEmit(e);
} else if (abs) {
const abs = this.opts.posix ? e.fullpathPosix() : e.fullpath();
this.matchEmit(abs + mark);
} else {
const rel = this.opts.posix ? e.relativePosix() : e.relative();
const pre =
this.opts.dotRelative && !rel.startsWith('..' + this.#sep) ?
'.' + this.#sep
: '';
this.matchEmit(!rel ? '.' + mark : pre + rel + mark);
}
async match(e, absolute, ifDir) {
const p = await this.matchCheck(e, ifDir);
if (p)
this.matchFinish(p, absolute);
}
async match(e, absolute, ifDir) {
const p = await this.matchCheck(e, ifDir);
if (p) this.matchFinish(p, absolute);
}
matchSync(e, absolute, ifDir) {
const p = this.matchCheckSync(e, ifDir);
if (p) this.matchFinish(p, absolute);
}
walkCB(target, patterns, cb) {
/* c8 ignore start */
if (this.signal?.aborted) cb();
/* c8 ignore stop */
this.walkCB2(target, patterns, new Processor(this.opts), cb);
}
walkCB2(target, patterns, processor, cb) {
if (this.#childrenIgnored(target)) return cb();
if (this.signal?.aborted) cb();
if (this.paused) {
this.onResume(() => this.walkCB2(target, patterns, processor, cb));
return;
}
matchSync(e, absolute, ifDir) {
const p = this.matchCheckSync(e, ifDir);
if (p)
this.matchFinish(p, absolute);
processor.processPatterns(target, patterns);
// done processing. all of the above is sync, can be abstracted out.
// subwalks is a map of paths to the entry filters they need
// matches is a map of paths to [absolute, ifDir] tuples.
let tasks = 1;
const next = () => {
if (--tasks === 0) cb();
};
for (const [m, absolute, ifDir] of processor.matches.entries()) {
if (this.#ignored(m)) continue;
tasks++;
this.match(m, absolute, ifDir).then(() => next());
}
walkCB(target, patterns, cb) {
/* c8 ignore start */
if (this.signal?.aborted)
cb();
/* c8 ignore stop */
this.walkCB2(target, patterns, new Processor(this.opts), cb);
for (const t of processor.subwalkTargets()) {
if (this.maxDepth !== Infinity && t.depth() >= this.maxDepth) {
continue;
}
tasks++;
const childrenCached = t.readdirCached();
if (t.calledReaddir()) this.walkCB3(t, childrenCached, processor, next);
else {
t.readdirCB(
(_, entries) => this.walkCB3(t, entries, processor, next),
true
);
}
}
walkCB2(target, patterns, processor, cb) {
if (this.#childrenIgnored(target))
return cb();
if (this.signal?.aborted)
cb();
if (this.paused) {
this.onResume(() => this.walkCB2(target, patterns, processor, cb));
return;
}
processor.processPatterns(target, patterns);
// done processing. all of the above is sync, can be abstracted out.
// subwalks is a map of paths to the entry filters they need
// matches is a map of paths to [absolute, ifDir] tuples.
let tasks = 1;
const next = () => {
if (--tasks === 0)
cb();
};
for (const [m, absolute, ifDir] of processor.matches.entries()) {
if (this.#ignored(m))
continue;
tasks++;
this.match(m, absolute, ifDir).then(() => next());
}
for (const t of processor.subwalkTargets()) {
if (this.maxDepth !== Infinity && t.depth() >= this.maxDepth) {
continue;
}
tasks++;
const childrenCached = t.readdirCached();
if (t.calledReaddir())
this.walkCB3(t, childrenCached, processor, next);
else {
t.readdirCB((_, entries) => this.walkCB3(t, entries, processor, next), true);
}
}
next();
next();
}
walkCB3(target, entries, processor, cb) {
processor = processor.filterEntries(target, entries);
let tasks = 1;
const next = () => {
if (--tasks === 0) cb();
};
for (const [m, absolute, ifDir] of processor.matches.entries()) {
if (this.#ignored(m)) continue;
tasks++;
this.match(m, absolute, ifDir).then(() => next());
}
walkCB3(target, entries, processor, cb) {
processor = processor.filterEntries(target, entries);
let tasks = 1;
const next = () => {
if (--tasks === 0)
cb();
};
for (const [m, absolute, ifDir] of processor.matches.entries()) {
if (this.#ignored(m))
continue;
tasks++;
this.match(m, absolute, ifDir).then(() => next());
}
for (const [target, patterns] of processor.subwalks.entries()) {
tasks++;
this.walkCB2(target, patterns, processor.child(), next);
}
next();
for (const [target, patterns] of processor.subwalks.entries()) {
tasks++;
this.walkCB2(target, patterns, processor.child(), next);
}
walkCBSync(target, patterns, cb) {
/* c8 ignore start */
if (this.signal?.aborted)
cb();
/* c8 ignore stop */
this.walkCB2Sync(target, patterns, new Processor(this.opts), cb);
next();
}
walkCBSync(target, patterns, cb) {
/* c8 ignore start */
if (this.signal?.aborted) cb();
/* c8 ignore stop */
this.walkCB2Sync(target, patterns, new Processor(this.opts), cb);
}
walkCB2Sync(target, patterns, processor, cb) {
if (this.#childrenIgnored(target)) return cb();
if (this.signal?.aborted) cb();
if (this.paused) {
this.onResume(() => this.walkCB2Sync(target, patterns, processor, cb));
return;
}
walkCB2Sync(target, patterns, processor, cb) {
if (this.#childrenIgnored(target))
return cb();
if (this.signal?.aborted)
cb();
if (this.paused) {
this.onResume(() => this.walkCB2Sync(target, patterns, processor, cb));
return;
}
processor.processPatterns(target, patterns);
// done processing. all of the above is sync, can be abstracted out.
// subwalks is a map of paths to the entry filters they need
// matches is a map of paths to [absolute, ifDir] tuples.
let tasks = 1;
const next = () => {
if (--tasks === 0)
cb();
};
for (const [m, absolute, ifDir] of processor.matches.entries()) {
if (this.#ignored(m))
continue;
this.matchSync(m, absolute, ifDir);
}
for (const t of processor.subwalkTargets()) {
if (this.maxDepth !== Infinity && t.depth() >= this.maxDepth) {
continue;
}
tasks++;
const children = t.readdirSync();
this.walkCB3Sync(t, children, processor, next);
}
next();
processor.processPatterns(target, patterns);
// done processing. all of the above is sync, can be abstracted out.
// subwalks is a map of paths to the entry filters they need
// matches is a map of paths to [absolute, ifDir] tuples.
let tasks = 1;
const next = () => {
if (--tasks === 0) cb();
};
for (const [m, absolute, ifDir] of processor.matches.entries()) {
if (this.#ignored(m)) continue;
this.matchSync(m, absolute, ifDir);
}
walkCB3Sync(target, entries, processor, cb) {
processor = processor.filterEntries(target, entries);
let tasks = 1;
const next = () => {
if (--tasks === 0)
cb();
};
for (const [m, absolute, ifDir] of processor.matches.entries()) {
if (this.#ignored(m))
continue;
this.matchSync(m, absolute, ifDir);
}
for (const [target, patterns] of processor.subwalks.entries()) {
tasks++;
this.walkCB2Sync(target, patterns, processor.child(), next);
}
next();
for (const t of processor.subwalkTargets()) {
if (this.maxDepth !== Infinity && t.depth() >= this.maxDepth) {
continue;
}
tasks++;
const children = t.readdirSync();
this.walkCB3Sync(t, children, processor, next);
}
next();
}
walkCB3Sync(target, entries, processor, cb) {
processor = processor.filterEntries(target, entries);
let tasks = 1;
const next = () => {
if (--tasks === 0) cb();
};
for (const [m, absolute, ifDir] of processor.matches.entries()) {
if (this.#ignored(m)) continue;
this.matchSync(m, absolute, ifDir);
}
for (const [target, patterns] of processor.subwalks.entries()) {
tasks++;
this.walkCB2Sync(target, patterns, processor.child(), next);
}
next();
}
}
export class GlobWalker extends GlobUtil {
matches = new Set();
constructor(patterns, path, opts) {
super(patterns, path, opts);
matches = new Set();
constructor(patterns, path, opts) {
super(patterns, path, opts);
}
matchEmit(e) {
this.matches.add(e);
}
async walk() {
if (this.signal?.aborted) throw this.signal.reason;
if (this.path.isUnknown()) {
await this.path.lstat();
}
matchEmit(e) {
this.matches.add(e);
}
async walk() {
if (this.signal?.aborted)
throw this.signal.reason;
if (this.path.isUnknown()) {
await this.path.lstat();
await new Promise((res, rej) => {
this.walkCB(this.path, this.patterns, () => {
if (this.signal?.aborted) {
rej(this.signal.reason);
} else {
res(this.matches);
}
await new Promise((res, rej) => {
this.walkCB(this.path, this.patterns, () => {
if (this.signal?.aborted) {
rej(this.signal.reason);
}
else {
res(this.matches);
}
});
});
return this.matches;
}
walkSync() {
if (this.signal?.aborted)
throw this.signal.reason;
if (this.path.isUnknown()) {
this.path.lstatSync();
}
// nothing for the callback to do, because this never pauses
this.walkCBSync(this.path, this.patterns, () => {
if (this.signal?.aborted)
throw this.signal.reason;
});
return this.matches;
});
});
return this.matches;
}
walkSync() {
if (this.signal?.aborted) throw this.signal.reason;
if (this.path.isUnknown()) {
this.path.lstatSync();
}
// nothing for the callback to do, because this never pauses
this.walkCBSync(this.path, this.patterns, () => {
if (this.signal?.aborted) throw this.signal.reason;
});
return this.matches;
}
}
export class GlobStream extends GlobUtil {
results;
constructor(patterns, path, opts) {
super(patterns, path, opts);
this.results = new Minipass({
signal: this.signal,
objectMode: true,
});
this.results.on('drain', () => this.resume());
this.results.on('resume', () => this.resume());
results;
constructor(patterns, path, opts) {
super(patterns, path, opts);
this.results = new Minipass({
signal: this.signal,
objectMode: true,
});
this.results.on('drain', () => this.resume());
this.results.on('resume', () => this.resume());
}
matchEmit(e) {
this.results.write(e);
if (!this.results.flowing) this.pause();
}
stream() {
const target = this.path;
if (target.isUnknown()) {
target.lstat().then(() => {
this.walkCB(target, this.patterns, () => this.results.end());
});
} else {
this.walkCB(target, this.patterns, () => this.results.end());
}
matchEmit(e) {
this.results.write(e);
if (!this.results.flowing)
this.pause();
}
stream() {
const target = this.path;
if (target.isUnknown()) {
target.lstat().then(() => {
this.walkCB(target, this.patterns, () => this.results.end());
});
}
else {
this.walkCB(target, this.patterns, () => this.results.end());
}
return this.results;
}
streamSync() {
if (this.path.isUnknown()) {
this.path.lstatSync();
}
this.walkCBSync(this.path, this.patterns, () => this.results.end());
return this.results;
return this.results;
}
streamSync() {
if (this.path.isUnknown()) {
this.path.lstatSync();
}
this.walkCBSync(this.path, this.patterns, () => this.results.end());
return this.results;
}
}
//# sourceMappingURL=walker.js.map
//# sourceMappingURL=walker.js.map