+1
-5
@@ -5,3 +5,3 @@ { | ||
| "description": "the most correct and second fastest glob implementation in JavaScript", | ||
| "version": "12.0.0", | ||
| "version": "13.0.0", | ||
| "type": "module", | ||
@@ -15,3 +15,2 @@ "tshy": { | ||
| }, | ||
| "bin": "./dist/esm/bin.mjs", | ||
| "main": "./dist/commonjs/index.js", | ||
@@ -71,7 +70,4 @@ "types": "./dist/commonjs/index.d.ts", | ||
| "dependencies": { | ||
| "foreground-child": "^3.3.1", | ||
| "jackspeak": "^4.1.1", | ||
| "minimatch": "^10.1.1", | ||
| "minipass": "^7.1.2", | ||
| "package-json-from-dist": "^1.0.0", | ||
| "path-scurry": "^2.0.0" | ||
@@ -78,0 +74,0 @@ }, |
+4
-120
@@ -153,124 +153,8 @@ # Glob | ||
| ``` | ||
| $ glob -h | ||
| The glob CLI has been moved to the `glob-bin` package, and must | ||
| be installed separately, as of version 13. | ||
| Usage: | ||
| glob [options] [<pattern> [<pattern> ...]] | ||
| Expand the positional glob expression arguments into any matching file system | ||
| paths found. | ||
| -c<command> --cmd=<command> | ||
| Run the command provided, passing the glob expression | ||
| matches as arguments. | ||
| -A --all 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 an argument whose filename is a glob | ||
| expression. | ||
| For example, if 'app/*.ts' would match 'app/[id].ts', | ||
| then on Windows powershell or cmd.exe, 'glob app/*.ts' | ||
| will expand to 'app/[id].ts', as expected. However, in | ||
| posix shells such as bash or zsh, the shell will first | ||
| expand 'app/*.ts' to a list of filenames. Then glob | ||
| will look for a file matching 'app/[id].ts' (ie, | ||
| 'app/i.ts' or 'app/d.ts'), which is unexpected. | ||
| Setting '--all' prevents this behavior, causing glob to | ||
| treat ALL patterns as glob expressions to be expanded, | ||
| even if they are an exact match to a file on disk. | ||
| When setting this option, be sure to enquote arguments | ||
| so that the shell will not expand them prior to passing | ||
| them to the glob command process. | ||
| -a --absolute Expand to absolute paths | ||
| -d --dot-relative Prepend './' on relative matches | ||
| -m --mark Append a / on any directories matched | ||
| -x --posix 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 paths, eg instead of 'C:\foo\bar', it | ||
| will expand to '//?/C:/foo/bar'. | ||
| -f --follow Follow symlinked directories when expanding '**' | ||
| -R --realpath 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. | ||
| -s --stat Call 'fs.lstat' on all entries, whether required or not | ||
| to determine if it's a valid match. | ||
| -b --match-base 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 Allow patterns to match files/directories that start | ||
| with '.', even if the pattern does not start with '.' | ||
| --nobrace Do not expand {...} patterns | ||
| --nocase Perform a case-insensitive match. This defaults to | ||
| 'true' on macOS and Windows platforms, 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-insensitive file systems, then the walk may return | ||
| more or less results than expected. | ||
| --nodir Do not match directories, only files. | ||
| Note: to *only* match directories, append a '/' at the | ||
| end of the pattern. | ||
| --noext Do not expand extglob patterns, such as '+(a|b)' | ||
| --noglobstar Do not expand '**' against multiple path portions. Ie, | ||
| treat it as a normal '*' instead. | ||
| --windows-path-no-escape | ||
| Use '\' as a path separator *only*, and *never* as an | ||
| escape character. If set, all '\' characters are | ||
| replaced with '/' in the pattern. | ||
| -D<n> --max-depth=<n> Maximum depth to traverse from the current working | ||
| directory | ||
| -C<cwd> --cwd=<cwd> Current working directory to execute/match in | ||
| -r<root> --root=<root> 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). | ||
| 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 still be matched in the 'cwd'. | ||
| To start absolute and non-absolute patterns in the same | ||
| path, you can use '--root=' to set it to the empty | ||
| string. 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. | ||
| --platform=<platform> Defaults to the value of 'process.platform' if | ||
| available, or 'linux' if not. Setting --platform=win32 | ||
| on non-Windows systems may cause strange behavior! | ||
| -i<ignore> --ignore=<ignore> | ||
| Glob patterns to ignore Can be set multiple times | ||
| -v --debug Output a huge amount of noisy debug information about | ||
| patterns as they are parsed and used to match files. | ||
| -h --help Show this usage information | ||
| ``` | ||
| npm install glob-bin | ||
| ``` | ||
@@ -277,0 +161,0 @@ ## `glob(pattern: string | string[], options?: GlobOptions) => Promise<string[] | Path[]>` |
| #!/usr/bin/env node | ||
| export {}; | ||
| //# sourceMappingURL=bin.d.mts.map |
| {"version":3,"file":"bin.d.mts","sourceRoot":"","sources":["../../src/bin.mts"],"names":[],"mappings":""} |
-345
| #!/usr/bin/env node | ||
| import { foregroundChild } from 'foreground-child'; | ||
| import { existsSync } from 'fs'; | ||
| import { jack } from 'jackspeak'; | ||
| import { loadPackageJson } from 'package-json-from-dist'; | ||
| import { basename, join } from 'path'; | ||
| import { globStream } from './index.js'; | ||
| const { version } = loadPackageJson(import.meta.url, '../package.json'); | ||
| const j = jack({ | ||
| usage: 'glob [options] [<pattern> [<pattern> ...]]', | ||
| }) | ||
| .description(` | ||
| Glob v${version} | ||
| Expand the positional glob expression arguments into any matching file | ||
| system paths found. | ||
| `) | ||
| .opt({ | ||
| cmd: { | ||
| short: 'c', | ||
| hint: 'command', | ||
| description: `Run the command provided, passing the glob expression | ||
| matches as arguments.`, | ||
| }, | ||
| }) | ||
| .opt({ | ||
| default: { | ||
| short: 'p', | ||
| hint: 'pattern', | ||
| description: `If no positional arguments are provided, glob will use | ||
| this pattern`, | ||
| }, | ||
| }) | ||
| .flag({ | ||
| shell: { | ||
| default: false, | ||
| description: `Interpret the command as a shell command by passing it | ||
| to the shell, with all matched filesystem paths appended, | ||
| **even if this cannot be done safely**. | ||
| This is **not** unsafe (and usually unnecessary) when using | ||
| the known Unix shells sh, bash, zsh, and fish, as these can | ||
| all be executed in such a way as to pass positional | ||
| arguments safely. | ||
| **Note**: THIS IS UNSAFE IF THE FILE PATHS ARE UNTRUSTED, | ||
| because a path like \`'some/path/\\$\\(cmd)'\` will be | ||
| executed by the shell. | ||
| If you do have positional arguments that you wish to pass to | ||
| the command ahead of the glob pattern matches, use the | ||
| \`--cmd-arg\`/\`-g\` option instead. | ||
| The next major release of glob will fully remove the ability | ||
| to use this option unsafely.`, | ||
| }, | ||
| }) | ||
| .optList({ | ||
| 'cmd-arg': { | ||
| short: 'g', | ||
| hint: 'arg', | ||
| default: [], | ||
| description: `Pass the provided values to the supplied command, ahead of | ||
| the glob matches. | ||
| For example, the command: | ||
| glob -c echo -g"hello" -g"world" *.txt | ||
| might output: | ||
| hello world a.txt b.txt | ||
| This is a safer (and future-proof) alternative than putting | ||
| positional arguments in the \`-c\`/\`--cmd\` option.`, | ||
| }, | ||
| }) | ||
| .flag({ | ||
| all: { | ||
| 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 | ||
| an argument whose filename is a glob expression. | ||
| For example, if 'app/*.ts' would match 'app/[id].ts', then | ||
| on Windows powershell or cmd.exe, 'glob app/*.ts' will | ||
| expand to 'app/[id].ts', as expected. However, in posix | ||
| shells such as bash or zsh, the shell will first expand | ||
| 'app/*.ts' to a list of filenames. Then glob will look | ||
| for a file matching 'app/[id].ts' (ie, 'app/i.ts' or | ||
| 'app/d.ts'), which is unexpected. | ||
| Setting '--all' prevents this behavior, causing glob | ||
| to treat ALL patterns as glob expressions to be expanded, | ||
| even if they are an exact match to a file on disk. | ||
| When setting this option, be sure to enquote arguments | ||
| so that the shell will not expand them prior to passing | ||
| them to the glob command process. | ||
| `, | ||
| }, | ||
| absolute: { | ||
| short: 'a', | ||
| description: 'Expand to absolute paths', | ||
| }, | ||
| 'dot-relative': { | ||
| short: 'd', | ||
| description: `Prepend './' on relative matches`, | ||
| }, | ||
| mark: { | ||
| short: 'm', | ||
| description: `Append a / on any directories matched`, | ||
| }, | ||
| posix: { | ||
| 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 paths, eg instead of 'C:\\foo\\bar', | ||
| it will expand to '//?/C:/foo/bar'. | ||
| `, | ||
| }, | ||
| follow: { | ||
| short: 'f', | ||
| description: `Follow symlinked directories when expanding '**'`, | ||
| }, | ||
| realpath: { | ||
| 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 | ||
| to determine if it's a valid match.`, | ||
| }, | ||
| 'match-base': { | ||
| 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 | ||
| with '.', even if the pattern does not start with '.' | ||
| `, | ||
| }, | ||
| nobrace: { | ||
| description: 'Do not expand {...} patterns', | ||
| }, | ||
| nocase: { | ||
| description: `Perform a case-insensitive match. This defaults to | ||
| 'true' on macOS and Windows platforms, 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-insensitive file systems, then the walk may return | ||
| more or less results than expected. | ||
| `, | ||
| }, | ||
| nodir: { | ||
| 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)'`, | ||
| }, | ||
| noglobstar: { | ||
| 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 | ||
| escape character. If set, all '\\' characters are | ||
| replaced with '/' in the pattern.`, | ||
| }, | ||
| }) | ||
| .num({ | ||
| 'max-depth': { | ||
| short: 'D', | ||
| description: `Maximum depth to traverse from the current | ||
| working directory`, | ||
| }, | ||
| }) | ||
| .opt({ | ||
| 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 | ||
| 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 | ||
| still be matched in the 'cwd'. | ||
| To start absolute and non-absolute patterns in the same | ||
| path, you can use '--root=' to set it to the empty | ||
| string. 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. | ||
| `, | ||
| }, | ||
| platform: { | ||
| 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', | ||
| ], | ||
| }, | ||
| }) | ||
| .optList({ | ||
| ignore: { | ||
| short: 'i', | ||
| description: `Glob patterns to ignore`, | ||
| }, | ||
| }) | ||
| .flag({ | ||
| debug: { | ||
| short: 'v', | ||
| description: `Output a huge amount of noisy debug information about | ||
| patterns as they are parsed and used to match files.`, | ||
| }, | ||
| version: { | ||
| short: 'V', | ||
| description: `Output the version (${version})`, | ||
| }, | ||
| help: { | ||
| short: 'h', | ||
| description: 'Show this usage information', | ||
| }, | ||
| }); | ||
| try { | ||
| const { positionals, values } = j.parse(); | ||
| const { cmd, shell, all, default: def, version: showVersion, help, absolute, cwd, dot, 'dot-relative': dotRelative, follow, ignore, 'match-base': matchBase, 'max-depth': maxDepth, mark, nobrace, nocase, nodir, noext, noglobstar, platform, realpath, root, stat, debug, posix, 'cmd-arg': cmdArg, } = values; | ||
| if (showVersion) { | ||
| console.log(version); | ||
| process.exit(0); | ||
| } | ||
| if (help) { | ||
| console.log(j.usage()); | ||
| process.exit(0); | ||
| } | ||
| //const { shell, help } = values | ||
| if (positionals.length === 0 && !def) | ||
| throw 'No patterns provided'; | ||
| if (positionals.length === 0 && def) | ||
| positionals.push(def); | ||
| const patterns = all ? positionals : positionals.filter(p => !existsSync(p)); | ||
| const matches = all ? [] : positionals.filter(p => existsSync(p)).map(p => join(p)); | ||
| const stream = globStream(patterns, { | ||
| absolute, | ||
| cwd, | ||
| dot, | ||
| dotRelative, | ||
| follow, | ||
| ignore, | ||
| mark, | ||
| matchBase, | ||
| maxDepth, | ||
| nobrace, | ||
| nocase, | ||
| nodir, | ||
| noext, | ||
| noglobstar, | ||
| platform: platform, | ||
| realpath, | ||
| root, | ||
| stat, | ||
| debug, | ||
| posix, | ||
| }); | ||
| if (!cmd) { | ||
| matches.forEach(m => console.log(m)); | ||
| stream.on('data', f => console.log(f)); | ||
| } | ||
| else { | ||
| cmdArg.push(...matches); | ||
| stream.on('data', f => cmdArg.push(f)); | ||
| // Attempt to support commands that contain spaces and otherwise require | ||
| // shell interpretation, but do NOT shell-interpret the arguments, to avoid | ||
| // injections via filenames. This affordance can only be done on known Unix | ||
| // shells, unfortunately. | ||
| // | ||
| // 'bash', ['-c', cmd + ' "$@"', 'bash', ...matches] | ||
| // 'zsh', ['-c', cmd + ' "$@"', 'zsh', ...matches] | ||
| // 'fish', ['-c', cmd + ' "$argv"', ...matches] | ||
| const { SHELL = 'unknown' } = process.env; | ||
| const shellBase = basename(SHELL); | ||
| const knownShells = ['sh', 'ksh', 'zsh', 'bash', 'fish']; | ||
| if ((shell || /[ "']/.test(cmd)) && knownShells.includes(shellBase)) { | ||
| const cmdWithArgs = `${cmd} "\$${shellBase === 'fish' ? 'argv' : '@'}"`; | ||
| if (shellBase !== 'fish') { | ||
| cmdArg.unshift(SHELL); | ||
| } | ||
| cmdArg.unshift('-c', cmdWithArgs); | ||
| stream.on('end', () => foregroundChild(SHELL, cmdArg)); | ||
| } | ||
| else { | ||
| if (shell) { | ||
| process.emitWarning('The --shell option is not supported on this system. To pass ' + | ||
| 'positional arguments to the subprocess, use -g/--cmd-arg instead.', 'UnsupportedWarning', 'GLOB_SHELL'); | ||
| } | ||
| stream.on('end', () => foregroundChild(cmd, cmdArg)); | ||
| } | ||
| } | ||
| } | ||
| catch (e) { | ||
| console.error(j.usage()); | ||
| console.error(e instanceof Error ? e.message : String(e)); | ||
| process.exit(1); | ||
| } | ||
| //# sourceMappingURL=bin.mjs.map |
| {"version":3,"file":"bin.mjs","sourceRoot":"","sources":["../../src/bin.mts"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAA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C,KAAK,EAAE,CAAC,CAAA;IACxB,OAAO,CAAC,KAAK,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { foregroundChild } from 'foreground-child'\nimport { existsSync } from 'fs'\nimport { jack } from 'jackspeak'\nimport { loadPackageJson } from 'package-json-from-dist'\nimport { basename, join } from 'path'\nimport { globStream } from './index.js'\n\nconst { version } = loadPackageJson(import.meta.url, '../package.json')\n\nconst j = jack({\n usage: 'glob [options] [<pattern> [<pattern> ...]]',\n})\n .description(\n `\n Glob v${version}\n\n Expand the positional glob expression arguments into any matching file\n system paths found.\n `,\n )\n .opt({\n cmd: {\n short: 'c',\n hint: 'command',\n description: `Run the command provided, passing the glob expression\n matches as arguments.`,\n },\n })\n .opt({\n default: {\n short: 'p',\n hint: 'pattern',\n description: `If no positional arguments are provided, glob will use\n this pattern`,\n },\n })\n .flag({\n shell: {\n default: false,\n description: `Interpret the command as a shell command by passing it\n to the shell, with all matched filesystem paths appended,\n **even if this cannot be done safely**.\n\n This is **not** unsafe (and usually unnecessary) when using\n the known Unix shells sh, bash, zsh, and fish, as these can\n all be executed in such a way as to pass positional\n arguments safely.\n\n **Note**: THIS IS UNSAFE IF THE FILE PATHS ARE UNTRUSTED,\n because a path like \\`'some/path/\\\\$\\\\(cmd)'\\` will be\n executed by the shell.\n\n If you do have positional arguments that you wish to pass to\n the command ahead of the glob pattern matches, use the\n \\`--cmd-arg\\`/\\`-g\\` option instead.\n\n The next major release of glob will fully remove the ability\n to use this option unsafely.`,\n },\n })\n .optList({\n 'cmd-arg': {\n short: 'g',\n hint: 'arg',\n default: [],\n description: `Pass the provided values to the supplied command, ahead of\n the glob matches.\n\n For example, the command:\n\n glob -c echo -g\"hello\" -g\"world\" *.txt\n\n might output:\n\n hello world a.txt b.txt\n\n This is a safer (and future-proof) alternative than putting\n positional arguments in the \\`-c\\`/\\`--cmd\\` option.`,\n },\n })\n .flag({\n all: {\n short: 'A',\n description: `By default, the glob cli command will not expand any\n arguments that are an exact match to a file on disk.\n\n This prevents double-expanding, in case the shell expands\n an argument whose filename is a glob expression.\n\n For example, if 'app/*.ts' would match 'app/[id].ts', then\n on Windows powershell or cmd.exe, 'glob app/*.ts' will\n expand to 'app/[id].ts', as expected. However, in posix\n shells such as bash or zsh, the shell will first expand\n 'app/*.ts' to a list of filenames. Then glob will look\n for a file matching 'app/[id].ts' (ie, 'app/i.ts' or\n 'app/d.ts'), which is unexpected.\n\n Setting '--all' prevents this behavior, causing glob\n to treat ALL patterns as glob expressions to be expanded,\n even if they are an exact match to a file on disk.\n\n When setting this option, be sure to enquote arguments\n so that the shell will not expand them prior to passing\n them to the glob command process.\n `,\n },\n absolute: {\n short: 'a',\n description: 'Expand to absolute paths',\n },\n 'dot-relative': {\n short: 'd',\n description: `Prepend './' on relative matches`,\n },\n mark: {\n short: 'm',\n description: `Append a / on any directories matched`,\n },\n posix: {\n short: 'x',\n description: `Always resolve to posix style paths, using '/' as the\n directory separator, even on Windows. Drive letter\n absolute matches on Windows will be expanded to their\n full resolved UNC paths, eg instead of 'C:\\\\foo\\\\bar',\n it will expand to '//?/C:/foo/bar'.\n `,\n },\n\n follow: {\n short: 'f',\n description: `Follow symlinked directories when expanding '**'`,\n },\n realpath: {\n short: 'R',\n description: `Call 'fs.realpath' on all of the results. In the case\n of an entry that cannot be resolved, the entry is\n omitted. This incurs a slight performance penalty, of\n course, because of the added system calls.`,\n },\n stat: {\n short: 's',\n description: `Call 'fs.lstat' on all entries, whether required or not\n to determine if it's a valid match.`,\n },\n 'match-base': {\n short: 'b',\n description: `Perform a basename-only match if the pattern does not\n contain any slash characters. That is, '*.js' would be\n treated as equivalent to '**/*.js', matching js files\n in all directories.\n `,\n },\n\n dot: {\n description: `Allow patterns to match files/directories that start\n with '.', even if the pattern does not start with '.'\n `,\n },\n nobrace: {\n description: 'Do not expand {...} patterns',\n },\n nocase: {\n description: `Perform a case-insensitive match. This defaults to\n 'true' on macOS and Windows platforms, and false on\n all others.\n\n Note: 'nocase' should only be explicitly set when it is\n known that the filesystem's case sensitivity differs\n from the platform default. If set 'true' on\n case-insensitive file systems, then the walk may return\n more or less results than expected.\n `,\n },\n nodir: {\n description: `Do not match directories, only files.\n\n Note: to *only* match directories, append a '/' at the\n end of the pattern.\n `,\n },\n noext: {\n description: `Do not expand extglob patterns, such as '+(a|b)'`,\n },\n noglobstar: {\n description: `Do not expand '**' against multiple path portions.\n Ie, treat it as a normal '*' instead.`,\n },\n 'windows-path-no-escape': {\n description: `Use '\\\\' as a path separator *only*, and *never* as an\n escape character. If set, all '\\\\' characters are\n replaced with '/' in the pattern.`,\n },\n })\n .num({\n 'max-depth': {\n short: 'D',\n description: `Maximum depth to traverse from the current\n working directory`,\n },\n })\n .opt({\n cwd: {\n short: 'C',\n description: 'Current working directory to execute/match in',\n default: process.cwd(),\n },\n root: {\n short: 'r',\n description: `A string path resolved against the 'cwd', which is\n used as the starting point for absolute patterns that\n start with '/' (but not drive letters or UNC paths\n on Windows).\n\n Note that this *doesn't* necessarily limit the walk to\n the 'root' directory, and doesn't affect the cwd\n starting point for non-absolute patterns. A pattern\n containing '..' will still be able to traverse out of\n the root directory, if it is not an actual root directory\n on the filesystem, and any non-absolute patterns will\n still be matched in the 'cwd'.\n\n To start absolute and non-absolute patterns in the same\n path, you can use '--root=' to set it to the empty\n string. However, be aware that on Windows systems, a\n pattern like 'x:/*' or '//host/share/*' will *always*\n start in the 'x:/' or '//host/share/' directory,\n regardless of the --root setting.\n `,\n },\n platform: {\n description: `Defaults to the value of 'process.platform' if\n available, or 'linux' if not. Setting --platform=win32\n on non-Windows systems may cause strange behavior!`,\n validOptions: [\n 'aix',\n 'android',\n 'darwin',\n 'freebsd',\n 'haiku',\n 'linux',\n 'openbsd',\n 'sunos',\n 'win32',\n 'cygwin',\n 'netbsd',\n ],\n },\n })\n .optList({\n ignore: {\n short: 'i',\n description: `Glob patterns to ignore`,\n },\n })\n .flag({\n debug: {\n short: 'v',\n description: `Output a huge amount of noisy debug information about\n patterns as they are parsed and used to match files.`,\n },\n version: {\n short: 'V',\n description: `Output the version (${version})`,\n },\n help: {\n short: 'h',\n description: 'Show this usage information',\n },\n })\n\ntry {\n const { positionals, values } = j.parse()\n const {\n cmd,\n shell,\n all,\n default: def,\n version: showVersion,\n help,\n absolute,\n cwd,\n dot,\n\n 'dot-relative': dotRelative,\n follow,\n ignore,\n 'match-base': matchBase,\n 'max-depth': maxDepth,\n mark,\n nobrace,\n nocase,\n nodir,\n noext,\n noglobstar,\n platform,\n realpath,\n root,\n stat,\n debug,\n posix,\n 'cmd-arg': cmdArg,\n } = values\n if (showVersion) {\n console.log(version)\n process.exit(0)\n }\n if (help) {\n console.log(j.usage())\n process.exit(0)\n }\n //const { shell, help } = values\n if (positionals.length === 0 && !def) throw 'No patterns provided'\n if (positionals.length === 0 && def) positionals.push(def)\n const patterns =\n all ? positionals : positionals.filter(p => !existsSync(p))\n const matches =\n all ? [] : positionals.filter(p => existsSync(p)).map(p => join(p))\n\n const stream = globStream(patterns, {\n absolute,\n cwd,\n dot,\n dotRelative,\n follow,\n ignore,\n mark,\n matchBase,\n maxDepth,\n nobrace,\n nocase,\n nodir,\n noext,\n noglobstar,\n platform: platform as undefined | NodeJS.Platform,\n realpath,\n root,\n stat,\n debug,\n posix,\n })\n\n if (!cmd) {\n matches.forEach(m => console.log(m))\n stream.on('data', f => console.log(f))\n } else {\n cmdArg.push(...matches)\n stream.on('data', f => cmdArg.push(f))\n // Attempt to support commands that contain spaces and otherwise require\n // shell interpretation, but do NOT shell-interpret the arguments, to avoid\n // injections via filenames. This affordance can only be done on known Unix\n // shells, unfortunately.\n //\n // 'bash', ['-c', cmd + ' \"$@\"', 'bash', ...matches]\n // 'zsh', ['-c', cmd + ' \"$@\"', 'zsh', ...matches]\n // 'fish', ['-c', cmd + ' \"$argv\"', ...matches]\n const { SHELL = 'unknown' } = process.env\n const shellBase = basename(SHELL)\n const knownShells = ['sh', 'ksh', 'zsh', 'bash', 'fish']\n if ((shell || /[ \"']/.test(cmd)) && knownShells.includes(shellBase)) {\n const cmdWithArgs = `${cmd} \"\\$${shellBase === 'fish' ? 'argv' : '@'}\"`\n if (shellBase !== 'fish') {\n cmdArg.unshift(SHELL)\n }\n cmdArg.unshift('-c', cmdWithArgs)\n stream.on('end', () => foregroundChild(SHELL, cmdArg))\n } else {\n if (shell) {\n process.emitWarning(\n 'The --shell option is not supported on this system. To pass ' +\n 'positional arguments to the subprocess, use -g/--cmd-arg instead.',\n 'UnsupportedWarning',\n 'GLOB_SHELL',\n )\n }\n stream.on('end', () => foregroundChild(cmd, cmdArg))\n }\n }\n} catch (e) {\n console.error(j.usage())\n console.error(e instanceof Error ? e.message : String(e))\n process.exit(1)\n}\n"]} |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
3
-50%8
-33.33%446402
-7.79%61
-6.15%4176
-7.26%1178
-8.96%- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed