Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/utils
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-03-19 17:33:40 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2021-03-19 18:36:06 +0300
commite94a45851dcfa08d5ce92b6f17cd868acae94ee4 (patch)
treebd2aa35afa648119478d74b25c0ea8a8cd41e991 /lib/utils
parentd98edd124a61d2331f45599ba6f6dfc42f07cbce (diff)
fix(suggestions): clarify Unknown command output
Base commands and `npm run` need different outputs PR-URL: https://github.com/npm/cli/pull/2906 Credit: @wraithgar Close: #2906 Reviewed-by: @ruyadorno
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/did-you-mean.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/utils/did-you-mean.js b/lib/utils/did-you-mean.js
index 5e41af67a..98133196e 100644
--- a/lib/utils/did-you-mean.js
+++ b/lib/utils/did-you-mean.js
@@ -23,10 +23,11 @@ const didYouMean = async (npm, path, scmd) => {
const best = [...bestCmd, ...bestRun, ...bestBin]
- const suggestion = best.length === 0 ? ''
- : best.length === 1 ? `\n\nDid you mean this?\n${best[0]}`
+ if (best.length === 0)
+ return ''
+
+ const suggestion = best.length === 1 ? `\n\nDid you mean this?\n${best[0]}`
: `\n\nDid you mean one of these?\n${best.slice(0, 3).join('\n')}`
- const result = `Unknown command: "${scmd}"${suggestion}`
- return result
+ return suggestion
}
module.exports = didYouMean