@pnpm/cli.parse-cli-args 1100.1.1 → 1100.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +22 -1
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -38,6 +38,7 @@ export async function parseCliArgs(opts, inputArgv) {
38
38
  argv: noptExploratoryResults.argv,
39
39
  cmd: null,
40
40
  options: {
41
+ ...pickUniversalOptions(),
41
42
  version: true,
42
43
  },
43
44
  params: noptExploratoryResults.argv.remain,
@@ -51,12 +52,32 @@ export async function parseCliArgs(opts, inputArgv) {
51
52
  return {
52
53
  argv: noptExploratoryResults.argv,
53
54
  cmd: 'help',
54
- options: {},
55
+ options: pickUniversalOptions(),
55
56
  params: noptExploratoryResults.argv.remain,
56
57
  unknownOptions: new Map(),
57
58
  fallbackCommandUsed: false,
58
59
  };
59
60
  }
61
+ // The --help and --version short-circuits skip the per-command nopt
62
+ // parse, so we still need to surface universal options the user typed
63
+ // alongside them — most importantly --pm-on-fail, which gates the
64
+ // packageManager / devEngines.packageManager check (#11487). Universal
65
+ // options were already typed and parsed by the exploratory nopt call,
66
+ // so we just pluck them back out and apply the same renamedOptions
67
+ // mapping the regular parse path uses (e.g. --prefix → dir), so
68
+ // consumers see consistent option names regardless of which path
69
+ // produced the result. Command-specific options are intentionally
70
+ // dropped; they belong to a command we are not running.
71
+ function pickUniversalOptions() {
72
+ const result = {};
73
+ for (const key of Object.keys(opts.universalOptionsTypes)) {
74
+ if (!(key in noptExploratoryResults))
75
+ continue;
76
+ const renamed = opts.renamedOptions?.[key] ?? key;
77
+ result[renamed] = noptExploratoryResults[key];
78
+ }
79
+ return result;
80
+ }
60
81
  const types = {
61
82
  ...opts.universalOptionsTypes,
62
83
  ...opts.getTypesByCommandName(commandName),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/cli.parse-cli-args",
3
- "version": "1100.1.1",
3
+ "version": "1100.1.2",
4
4
  "description": "Parses the CLI args passed to pnpm",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -32,7 +32,7 @@
32
32
  "devDependencies": {
33
33
  "@jest/globals": "30.3.0",
34
34
  "tempy": "3.0.0",
35
- "@pnpm/cli.parse-cli-args": "1100.1.1"
35
+ "@pnpm/cli.parse-cli-args": "1100.1.2"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=22.13"