@pnpm/cli.parse-cli-args 1000.1.4 → 1100.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +23 -2
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import nopt from '@pnpm/nopt';
|
|
|
3
3
|
import { findWorkspaceDir } from '@pnpm/workspace.root-finder';
|
|
4
4
|
import didYouMean, { ReturnTypeEnums } from 'didyoumean2';
|
|
5
5
|
const RECURSIVE_CMDS = new Set(['recursive', 'multi', 'm']);
|
|
6
|
-
const SPECIALLY_ESCAPED_CMDS = new Set(['run', 'dlx']);
|
|
6
|
+
const SPECIALLY_ESCAPED_CMDS = new Set(['run', 'dlx', 'with']);
|
|
7
7
|
export async function parseCliArgs(opts, inputArgv) {
|
|
8
8
|
const noptExploratoryResults = nopt({
|
|
9
9
|
filter: [String],
|
|
@@ -88,13 +88,34 @@ export async function parseCliArgs(opts, inputArgv) {
|
|
|
88
88
|
(fallbackCommandUsed && opts.fallbackCommand === 'run' ? -1 : 0);
|
|
89
89
|
return [noptExploratoryResults.argv.remain[indexOfRunScriptName]];
|
|
90
90
|
}
|
|
91
|
+
// When "config" is a registered CLI option (e.g. `pnpm add --config`),
|
|
92
|
+
// nopt captures --config.xxx=yyy as the "config" flag value instead of
|
|
93
|
+
// treating it as the nconf-style config override syntax. Work around this
|
|
94
|
+
// by rewriting --config.xxx=yyy to a placeholder before nopt, then restoring.
|
|
95
|
+
const hasConfigOption = 'config' in types;
|
|
96
|
+
const configDotArgs = [];
|
|
97
|
+
const filteredArgv = hasConfigOption
|
|
98
|
+
? inputArgv.map(arg => {
|
|
99
|
+
if (arg.startsWith('--config.')) {
|
|
100
|
+
configDotArgs.push(arg);
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
return arg;
|
|
104
|
+
}).filter((arg) => arg !== undefined)
|
|
105
|
+
: inputArgv;
|
|
91
106
|
const { argv, ...options } = nopt({
|
|
92
107
|
recursive: Boolean,
|
|
93
108
|
...types,
|
|
94
109
|
}, {
|
|
95
110
|
...opts.universalShorthands,
|
|
96
111
|
...opts.shorthandsByCommandName[commandName],
|
|
97
|
-
},
|
|
112
|
+
}, filteredArgv, 0, { escapeArgs: getEscapeArgsWithSpecialCases() });
|
|
113
|
+
// Re-parse extracted --config.xxx args through nopt so they get proper
|
|
114
|
+
// type coercion (e.g. "false" → false for Boolean settings).
|
|
115
|
+
if (configDotArgs.length > 0) {
|
|
116
|
+
const { argv: _, ...configOptions } = nopt({}, {}, configDotArgs, 0);
|
|
117
|
+
Object.assign(options, configOptions);
|
|
118
|
+
}
|
|
98
119
|
const workspaceDir = await getWorkspaceDir(options);
|
|
99
120
|
// For the run command, it's not clear whether --help should be passed to the
|
|
100
121
|
// underlying script or invoke pnpm's help text until an additional nopt call.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/cli.parse-cli-args",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1100.1.0",
|
|
4
4
|
"description": "Parses the CLI args passed to pnpm",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@pnpm/nopt": "^0.3.1",
|
|
28
28
|
"didyoumean2": "^7.0.4",
|
|
29
|
-
"@pnpm/
|
|
30
|
-
"@pnpm/
|
|
29
|
+
"@pnpm/error": "1100.0.0",
|
|
30
|
+
"@pnpm/workspace.root-finder": "1100.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"tempy": "3.0.0",
|
|
34
|
-
"@pnpm/cli.parse-cli-args": "
|
|
34
|
+
"@pnpm/cli.parse-cli-args": "1100.1.0"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=22.13"
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
44
|
-
"
|
|
45
|
-
"test": "pnpm run compile && pnpm run _test",
|
|
44
|
+
"test": "pn compile && pn .test",
|
|
46
45
|
"start": "tsgo --watch",
|
|
47
|
-
"compile": "tsgo --build &&
|
|
46
|
+
"compile": "tsgo --build && pn lint --fix",
|
|
47
|
+
".test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest"
|
|
48
48
|
}
|
|
49
49
|
}
|