fix: show full parent command path in subcommand usage errors (#9404) · npm/cli@fe41ae7 · GitHub
Skip to content

Commit fe41ae7

Browse files
authored
fix: show full parent command path in subcommand usage errors (#9404)
1 parent 75bf7de commit fe41ae7

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

lib/base-cmd.js

Lines changed: 4 additions & 2 deletions

lib/npm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,13 @@ class Npm {
241241

242242
// Check if help is requested for the subcommand
243243
if (this.config.get('usage')) {
244-
const parentName = commandPath[0]
244+
const parentName = commandPath.join(' ')
245245
return output.standard(SubCommand.getUsage(parentName))
246246
}
247247

248248
// Create subcommand instance and recurse
249249
const subcommandInstance = new SubCommand(this)
250+
subcommandInstance.parentName = commandPath.join(' ')
250251
const subcommandArgs = args.slice(1) // Remove subcommand name from args
251252
const subcommandPath = [...commandPath, subcommandName]
252253

tap-snapshots/test/lib/commands/install.js.test.cjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ silly logfile done cleaning log files
134134
verbose stack Error: The developer of this package has specified the following through devEngines
135135
verbose stack Invalid devEngines.runtime
136136
verbose stack Invalid name "nondescript" does not match "node" for "runtime"
137-
verbose stack at Install.checkDevEngines ({CWD}/lib/base-cmd.js:247:27)
138-
verbose stack at MockNpm.execCommandClass ({CWD}/lib/npm.js:281:7)
137+
verbose stack at Install.checkDevEngines ({CWD}/lib/base-cmd.js:249:27)
138+
verbose stack at MockNpm.execCommandClass ({CWD}/lib/npm.js:282:7)
139139
verbose stack at MockNpm.exec ({CWD}/lib/npm.js:182:9)
140140
error code EBADDEVENGINES
141141
error EBADDEVENGINES The developer of this package has specified the following through devEngines
@@ -199,8 +199,8 @@ warn EBADDEVENGINES }
199199
verbose stack Error: The developer of this package has specified the following through devEngines
200200
verbose stack Invalid devEngines.runtime
201201
verbose stack Invalid name "nondescript" does not match "node" for "runtime"
202-
verbose stack at Install.checkDevEngines ({CWD}/lib/base-cmd.js:247:27)
203-
verbose stack at MockNpm.execCommandClass ({CWD}/lib/npm.js:281:7)
202+
verbose stack at Install.checkDevEngines ({CWD}/lib/base-cmd.js:249:27)
203+
verbose stack at MockNpm.execCommandClass ({CWD}/lib/npm.js:282:7)
204204
verbose stack at MockNpm.exec ({CWD}/lib/npm.js:182:9)
205205
error code EBADDEVENGINES
206206
error EBADDEVENGINES The developer of this package has specified the following through devEngines
@@ -225,8 +225,8 @@ silly logfile done cleaning log files
225225
verbose stack Error: The developer of this package has specified the following through devEngines
226226
verbose stack Invalid devEngines.runtime
227227
verbose stack Invalid name "nondescript" does not match "node" for "runtime"
228-
verbose stack at Install.checkDevEngines ({CWD}/lib/base-cmd.js:247:27)
229-
verbose stack at MockNpm.execCommandClass ({CWD}/lib/npm.js:281:7)
228+
verbose stack at Install.checkDevEngines ({CWD}/lib/base-cmd.js:249:27)
229+
verbose stack at MockNpm.execCommandClass ({CWD}/lib/npm.js:282:7)
230230
verbose stack at MockNpm.exec ({CWD}/lib/npm.js:182:9)
231231
error code EBADDEVENGINES
232232
error EBADDEVENGINES The developer of this package has specified the following through devEngines

test/lib/commands/stage/approve.js

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)