Skip to content

Commit 93a061d

Browse files
wraithgarruyadorno
authored andcommitted
fix(usage): add action items to error output
PR-URL: #2917 Credit: @wraithgar Close: #2917 Reviewed-by: @ruyadorno
1 parent e1b3b31 commit 93a061d

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

lib/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module.exports = (process) => {
6767
if (cmd) {
6868
const didYouMean = require('./utils/did-you-mean.js')
6969
const suggestions = await didYouMean(npm, npm.localPrefix, cmd)
70-
npm.output(`Unknown command: "${cmd}"${suggestions}`)
70+
npm.output(`Unknown command: "${cmd}"${suggestions}\n\nTo see a list of supported npm commands, run:\n npm help`)
7171
} else
7272
npm.output(npm.usage)
7373
process.exitCode = 1

lib/run-script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class RunScript extends BaseCommand {
9191
return
9292

9393
const suggestions = await didYouMean(this.npm, path, event)
94-
throw new Error(`Missing script: "${event}"${suggestions}`)
94+
throw new Error(`Missing script: "${event}"${suggestions}\n\nTo see a list of scripts, run:\n npm run`)
9595
}
9696

9797
// positional args only added to the main event, not pre/post

test/lib/run-script.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -896,27 +896,27 @@ t.test('workspaces', t => {
896896
t.match(RUN_SCRIPTS, [])
897897
t.strictSame(LOG.map(cleanOutput), [
898898
'Lifecycle script `missing-script` failed with error:',
899-
'Error: Missing script: "missing-script"',
899+
'Error: Missing script: "missing-script"\n\nTo see a list of scripts, run:\n npm run',
900900
' in workspace: [email protected]',
901901
' at location: {CWD}/test/lib/run-script-workspaces/packages/a',
902902
'Lifecycle script `missing-script` failed with error:',
903-
'Error: Missing script: "missing-script"',
903+
'Error: Missing script: "missing-script"\n\nTo see a list of scripts, run:\n npm run',
904904
' in workspace: [email protected]',
905905
' at location: {CWD}/test/lib/run-script-workspaces/packages/b',
906906
'Lifecycle script `missing-script` failed with error:',
907-
'Error: Missing script: "missing-script"',
907+
'Error: Missing script: "missing-script"\n\nTo see a list of scripts, run:\n npm run',
908908
' in workspace: [email protected]',
909909
' at location: {CWD}/test/lib/run-script-workspaces/packages/c',
910910
'Lifecycle script `missing-script` failed with error:',
911-
'Error: Missing script: "missing-script"',
911+
'Error: Missing script: "missing-script"\n\nTo see a list of scripts, run:\n npm run',
912912
' in workspace: [email protected]',
913913
' at location: {CWD}/test/lib/run-script-workspaces/packages/d',
914914
'Lifecycle script `missing-script` failed with error:',
915-
'Error: Missing script: "missing-script"',
915+
'Error: Missing script: "missing-script"\n\nTo see a list of scripts, run:\n npm run',
916916
' in workspace: e',
917917
' at location: {CWD}/test/lib/run-script-workspaces/packages/e',
918918
'Lifecycle script `missing-script` failed with error:',
919-
'Error: Missing script: "missing-script"',
919+
'Error: Missing script: "missing-script"\n\nTo see a list of scripts, run:\n npm run',
920920
' in workspace: [email protected]',
921921
' at location: {CWD}/test/lib/run-script-workspaces/packages/noscripts',
922922
], 'should log error msgs for each workspace script')
@@ -937,11 +937,11 @@ t.test('workspaces', t => {
937937
t.match(RUN_SCRIPTS, [])
938938
t.strictSame(LOG.map(cleanOutput), [
939939
'Lifecycle script `test` failed with error:',
940-
'Error: Missing script: "test"',
940+
'Error: Missing script: "test"\n\nTo see a list of scripts, run:\n npm run',
941941
' in workspace: [email protected]',
942942
' at location: {CWD}/test/lib/run-script-workspaces/packages/a',
943943
'Lifecycle script `test` failed with error:',
944-
'Error: Missing script: "test"',
944+
'Error: Missing script: "test"\n\nTo see a list of scripts, run:\n npm run',
945945
' in workspace: [email protected]',
946946
' at location: {CWD}/test/lib/run-script-workspaces/packages/b',
947947
], 'should log error msgs for each workspace script')

0 commit comments

Comments
 (0)