@pnpm/cli.parse-cli-args 1100.1.2 → 1100.1.4
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 +33 -13
- package/package.json +9 -6
package/lib/index.js
CHANGED
|
@@ -30,7 +30,7 @@ export async function parseCliArgs(opts, inputArgv) {
|
|
|
30
30
|
if (noptExploratoryResults['help']) {
|
|
31
31
|
return {
|
|
32
32
|
...getParsedArgsForHelp(),
|
|
33
|
-
workspaceDir: await getWorkspaceDir(noptExploratoryResults),
|
|
33
|
+
workspaceDir: await getWorkspaceDir(noptExploratoryResults, opts.renamedOptions),
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
if (noptExploratoryResults['version'] || noptExploratoryResults['v']) {
|
|
@@ -44,7 +44,7 @@ export async function parseCliArgs(opts, inputArgv) {
|
|
|
44
44
|
params: noptExploratoryResults.argv.remain,
|
|
45
45
|
unknownOptions: new Map(),
|
|
46
46
|
fallbackCommandUsed: false,
|
|
47
|
-
workspaceDir: await getWorkspaceDir(noptExploratoryResults),
|
|
47
|
+
workspaceDir: await getWorkspaceDir(noptExploratoryResults, opts.renamedOptions),
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -137,6 +137,23 @@ export async function parseCliArgs(opts, inputArgv) {
|
|
|
137
137
|
const { argv: _, ...configOptions } = nopt({}, {}, configDotArgs, 0);
|
|
138
138
|
Object.assign(options, configOptions);
|
|
139
139
|
}
|
|
140
|
+
// Apply renamedOptions before workspace detection so `--prefix=foo`
|
|
141
|
+
// (renamed to `dir`) participates in finding the workspace root.
|
|
142
|
+
// Otherwise getWorkspaceDir falls back to process.cwd() and the
|
|
143
|
+
// workspace manifest at the prefix dir is missed (#11535).
|
|
144
|
+
// The canonical option wins if both are supplied (e.g. `--prefix=foo
|
|
145
|
+
// --dir=bar` keeps `dir=bar`); the alias is always dropped.
|
|
146
|
+
if (opts.renamedOptions != null) {
|
|
147
|
+
for (const [cliOption, optionValue] of Object.entries(options)) {
|
|
148
|
+
const target = opts.renamedOptions[cliOption];
|
|
149
|
+
if (target) {
|
|
150
|
+
if (!(target in options)) {
|
|
151
|
+
options[target] = optionValue;
|
|
152
|
+
}
|
|
153
|
+
delete options[cliOption];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
140
157
|
const workspaceDir = await getWorkspaceDir(options);
|
|
141
158
|
// For the run command, it's not clear whether --help should be passed to the
|
|
142
159
|
// underlying script or invoke pnpm's help text until an additional nopt call.
|
|
@@ -146,14 +163,6 @@ export async function parseCliArgs(opts, inputArgv) {
|
|
|
146
163
|
workspaceDir,
|
|
147
164
|
};
|
|
148
165
|
}
|
|
149
|
-
if (opts.renamedOptions != null) {
|
|
150
|
-
for (const [cliOption, optionValue] of Object.entries(options)) {
|
|
151
|
-
if (opts.renamedOptions[cliOption]) {
|
|
152
|
-
options[opts.renamedOptions[cliOption]] = optionValue;
|
|
153
|
-
delete options[cliOption];
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
166
|
const params = argv.remain.slice(1);
|
|
158
167
|
if (options['recursive'] !== true && (options['filter'] || options['filter-prod'] || recursiveCommandUsed)) {
|
|
159
168
|
options['recursive'] = true;
|
|
@@ -222,10 +231,21 @@ function getClosestOptionMatches(knownOptions, option) {
|
|
|
222
231
|
returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,
|
|
223
232
|
});
|
|
224
233
|
}
|
|
225
|
-
async function getWorkspaceDir(parsedOpts) {
|
|
234
|
+
async function getWorkspaceDir(parsedOpts, renamedOptions) {
|
|
226
235
|
if (parsedOpts['global'] || parsedOpts['ignore-workspace'])
|
|
227
236
|
return undefined;
|
|
228
|
-
|
|
229
|
-
|
|
237
|
+
// Look up dir, also honoring renamed options like `prefix → dir` so that
|
|
238
|
+
// `--prefix` works even on code paths that read parsedOpts before the
|
|
239
|
+
// rename loop has run (e.g. the --help/--version short-circuits).
|
|
240
|
+
let dir = parsedOpts['dir'];
|
|
241
|
+
if (dir == null && renamedOptions != null) {
|
|
242
|
+
for (const [from, to] of Object.entries(renamedOptions)) {
|
|
243
|
+
if (to === 'dir' && parsedOpts[from] != null) {
|
|
244
|
+
dir = parsedOpts[from];
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return findWorkspaceDir((dir ?? process.cwd()));
|
|
230
250
|
}
|
|
231
251
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/cli.parse-cli-args",
|
|
3
|
-
"version": "1100.1.
|
|
3
|
+
"version": "1100.1.4",
|
|
4
4
|
"description": "Parses the CLI args passed to pnpm",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"funding": "https://opencollective.com/pnpm",
|
|
11
|
-
"repository":
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/pnpm/pnpm/tree/main/cli/parse-cli-args"
|
|
14
|
+
},
|
|
12
15
|
"homepage": "https://github.com/pnpm/pnpm/tree/main/cli/parse-cli-args#readme",
|
|
13
16
|
"bugs": {
|
|
14
17
|
"url": "https://github.com/pnpm/pnpm/issues"
|
|
@@ -26,13 +29,13 @@
|
|
|
26
29
|
"dependencies": {
|
|
27
30
|
"@pnpm/nopt": "^0.3.1",
|
|
28
31
|
"didyoumean2": "^7.0.4",
|
|
29
|
-
"@pnpm/
|
|
30
|
-
"@pnpm/
|
|
32
|
+
"@pnpm/workspace.root-finder": "1100.0.2",
|
|
33
|
+
"@pnpm/error": "1100.0.0"
|
|
31
34
|
},
|
|
32
35
|
"devDependencies": {
|
|
33
|
-
"@jest/globals": "30.
|
|
36
|
+
"@jest/globals": "30.4.1",
|
|
34
37
|
"tempy": "3.0.0",
|
|
35
|
-
"@pnpm/cli.parse-cli-args": "1100.1.
|
|
38
|
+
"@pnpm/cli.parse-cli-args": "1100.1.4"
|
|
36
39
|
},
|
|
37
40
|
"engines": {
|
|
38
41
|
"node": ">=22.13"
|