diff options
author | isaacs <i@izs.me> | 2020-03-17 19:53:01 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2020-05-08 04:12:57 +0300 |
commit | cd9f70f9f0466ecb4228fc0b25b3f2034af17b29 (patch) | |
tree | 751aa9dcfcf486ddaa21ee949682de29d54f6008 | |
parent | 2eee7a4376d765218c8804deb48da3de760fd6cc (diff) |
Fix (with hacky temporary code in some cases) usage output for all commands
-rw-r--r-- | lib/audit.js | 2 | ||||
-rw-r--r-- | lib/dedupe.js | 4 | ||||
-rw-r--r-- | lib/help.js | 4 | ||||
-rw-r--r-- | lib/hook.js | 2 | ||||
-rw-r--r-- | lib/prune.js | 3 | ||||
-rw-r--r-- | lib/uninstall.js | 3 | ||||
-rw-r--r-- | lib/unpublish.js | 8 |
7 files changed, 16 insertions, 10 deletions
diff --git a/lib/audit.js b/lib/audit.js index 29101965e..e34f14f9f 100644 --- a/lib/audit.js +++ b/lib/audit.js @@ -55,7 +55,7 @@ auditCmd.completion = function (opts, cb) { } } -class Auditor extends Installer { +class Auditor extends (class {}) { constructor (where, dryrun, args, opts) { super(where, dryrun, args, opts) this.deepArgs = (opts && opts.deepArgs) || [] diff --git a/lib/dedupe.js b/lib/dedupe.js index 325faeaab..5174013a3 100644 --- a/lib/dedupe.js +++ b/lib/dedupe.js @@ -1,3 +1,5 @@ +// XXX replace this with @npmcli/arborist + var util = require('util') var path = require('path') var validate = require('aproba') @@ -47,7 +49,7 @@ function Deduper (where, dryrun) { this.noPackageJsonOk = true this.topLevelLifecycles = false } -util.inherits(Deduper, Installer) +util.inherits(Deduper, class {}) // Installer) Deduper.prototype.loadIdealTree = function (cb) { validate('F', arguments) diff --git a/lib/help.js b/lib/help.js index 61f1f3f94..2f761a7f1 100644 --- a/lib/help.js +++ b/lib/help.js @@ -18,6 +18,10 @@ var shorthands = require('./config/cmd-list').shorthands var commands = cmdList.concat(Object.keys(shorthands)) var output = require('./utils/output.js') +const usage = require('./utils/usage.js') + +help.usage = usage('help', 'npm help <term> [<terms..>]') + function help (args, cb) { var argv = npm.config.get('argv').cooked diff --git a/lib/hook.js b/lib/hook.js index dd19e2a39..3f189dd80 100644 --- a/lib/hook.js +++ b/lib/hook.js @@ -32,6 +32,8 @@ module.exports = (args, cb) => Promise.resolve().then(() => { .catch(err => err.code === 'EUSAGE' ? cb(err.message) : cb(err)) }) +module.exports.usage = hook.usage + function hook (args) { return otplease(npm.flatOptions, opts => { switch (args[0]) { diff --git a/lib/prune.js b/lib/prune.js index 010e471e4..62c9a9225 100644 --- a/lib/prune.js +++ b/lib/prune.js @@ -1,3 +1,4 @@ +// XXX replace this with @npmcli/arborist // prune extraneous packages. module.exports = prune @@ -28,7 +29,7 @@ function Pruner (where, dryrun, args) { Installer.call(this, where, dryrun, args) this.autoPrune = true } -util.inherits(Pruner, Installer) +util.inherits(Pruner, class {}) // Installer) Pruner.prototype.loadAllDepsIntoIdealTree = function (cb) { log.silly('uninstall', 'loadAllDepsIntoIdealTree') diff --git a/lib/uninstall.js b/lib/uninstall.js index c4bd23ea3..1c7a89d32 100644 --- a/lib/uninstall.js +++ b/lib/uninstall.js @@ -1,4 +1,5 @@ 'use strict' +// XXX replace this with @npmcli/arborist // remove a package. module.exports = uninstall @@ -48,7 +49,7 @@ function uninstall (args, cb) { } } -class Uninstaller extends Installer { +class Uninstaller extends (class {}) { constructor (where, dryrun, args) { super(where, dryrun, args) this.remove = [] diff --git a/lib/unpublish.js b/lib/unpublish.js index 90ddfcbc4..2d766e831 100644 --- a/lib/unpublish.js +++ b/lib/unpublish.js @@ -20,11 +20,7 @@ const readJson = BB.promisify(require('read-package-json')) const usage = require('./utils/usage.js') const whoami = BB.promisify(require('./whoami.js')) -unpublish.usage = usage( - 'unpublish', - '\nnpm unpublish [<@scope>/]<pkg>@<version>' + - '\nnpm unpublish [<@scope>/]<pkg> --force' -) +unpublish.usage = usage('unpublish', 'npm unpublish [<@scope>/]<pkg>[@<version>]') function UsageError () { throw Object.assign(new Error(`Usage: ${unpublish.usage}`), { @@ -79,7 +75,7 @@ function unpublish (args, cb) { 'Refusing to delete entire project.\n' + 'Run with --force to do this.\n' + unpublish.usage - ), { code: 'EUSAGE' }) + ), {code: 'EUSAGE'}) } if (!spec || path.resolve(spec.name) === npm.localPrefix) { // if there's a package.json in the current folder, then |