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
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-03-11 03:11:34 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2021-03-18 22:54:36 +0300
commit41facf6435ced4e416d74111d9c3ff00ee19ab7d (patch)
tree1a6644f756670ee6fad67a9a59d135dc0f3e00ef /lib/npm.js
parenta8d0751e4b7c7d8b808c8a49f288fc7272f729b0 (diff)
feat(help): refactor npm help/help-search
Lots of dead code removed thanks to streamlining of logic. `npm help` `npm <command>` and `npm help-search` are all now separated concerns, handling their own use cases. `help` calls `help-search` as a last resort, but `npm <command>` no longer tries to wind its way through to `help-search` just to get the basic npm usage displayed. The `did you mean` output has been expanded. It now always suggests top level commands, scripts, and bins, and suggests them in the way they should be called. PR-URL: https://github.com/npm/cli/pull/2859 Credit: @wraithgar Close: #2859 Reviewed-by: @ruyadorno
Diffstat (limited to 'lib/npm.js')
-rw-r--r--lib/npm.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/npm.js b/lib/npm.js
index d80067a11..78b6ba034 100644
--- a/lib/npm.js
+++ b/lib/npm.js
@@ -38,6 +38,7 @@ const proxyCmds = new Proxy({}, {
const { definitions, flatten, shorthands } = require('./utils/config/index.js')
const { shellouts } = require('./utils/cmd-list.js')
+const usage = require('./utils/npm-usage.js')
let warnedNonDashArg = false
const _runCmd = Symbol('_runCmd')
@@ -100,7 +101,7 @@ const npm = module.exports = new class extends EventEmitter {
}
if (this.config.get('usage')) {
- console.log(impl.usage)
+ this.output(impl.usage)
cb()
} else {
impl.exec(args, er => {
@@ -274,6 +275,10 @@ const npm = module.exports = new class extends EventEmitter {
this[k] = r
}
+ get usage () {
+ return usage(this)
+ }
+
// XXX add logging to see if we actually use this
get tmp () {
if (!this[_tmpFolder]) {