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:
authorisaacs <i@izs.me>2020-08-04 08:56:34 +0300
committerisaacs <i@izs.me>2020-08-04 11:03:34 +0300
commit108a4fcb5da23c34690b4767a4c5f7f93ab99c0d (patch)
tree15254742f9e81012fd8d50d6621d9178d2f6977d /lib/prefix.js
parent0b63d5078a5858b83dba943720c6d6dfe6eb808f (diff)
refactor and lint commands, make consistent
Still pending test coverage for most of these, but wanted to give them a clean sweep to get the "load-all-commands" tests passing. The following changes are in here: - All commands now have a `completion()` method and a usage string that uses the same `usage` util consistently. - The `silent` argument to many commands has been removed. - All commands use the `cmd = ${cmd}(args).then(() => cb()).catch(cb)` pattern consistently. Full test coverage for all commands is still lacking, and will have to be done prior to the GA v7 release.
Diffstat (limited to 'lib/prefix.js')
-rw-r--r--lib/prefix.js23
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/prefix.js b/lib/prefix.js
index fb20389c4..0a9914473 100644
--- a/lib/prefix.js
+++ b/lib/prefix.js
@@ -1,15 +1,8 @@
-module.exports = prefix
-
-var npm = require('./npm.js')
-var output = require('./utils/output.js')
-
-prefix.usage = 'npm prefix [-g]'
-
-function prefix (args, silent, cb) {
- if (typeof cb !== 'function') {
- cb = silent
- silent = false
- }
- if (!silent) output(npm.prefix)
- process.nextTick(cb.bind(this, null, npm.prefix))
-}
+const npm = require('./npm.js')
+const output = require('./utils/output.js')
+const usageUtil = require('./utils/usage.js')
+const completion = require('./utils/completion/none.js')
+const cmd = (args, cb) => prefix(args).then(() => cb()).catch(cb)
+const usage = usageUtil('prefix', 'npm prefix [-g]')
+const prefix = async (args, cb) => output(npm.prefix)
+module.exports = Object.assign(cmd, { usage, completion })