diff options
author | Gar <gar+gh@danger.computer> | 2021-03-04 07:26:33 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-03-09 22:10:06 +0300 |
commit | 9fe0df5b5d7606e5841288d9931be6c04767c9ca (patch) | |
tree | 50b916523fe4a5ebab6010b137cc931cc2a9ce70 /lib/utils | |
parent | 85a8694dd9b4a924a474ba75261914511a216868 (diff) |
fix(usage): clean up usage declarations
Small refactor of commands to allow usage to be more programmatically
generated, leading us in the direction of more tighly coupling each
command to the params it accepts.
PR-URL: https://github.com/npm/cli/pull/2821
Credit: @wraithgar
Close: #2821
Reviewed-by: @isaacs
Diffstat (limited to 'lib/utils')
-rw-r--r-- | lib/utils/lifecycle-cmd.js | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/utils/lifecycle-cmd.js b/lib/utils/lifecycle-cmd.js index 8be9b5a12..1917bef36 100644 --- a/lib/utils/lifecycle-cmd.js +++ b/lib/utils/lifecycle-cmd.js @@ -1,19 +1,14 @@ // The implementation of commands that are just "run a script" // restart, start, stop, test -const usageUtil = require('./usage.js') -class LifecycleCmd { - constructor (npm, stage) { - this.npm = npm - this.stage = stage - } - - get usage () { - return usageUtil(this.stage, `npm ${this.stage} [-- <args>]`) +const BaseCommand = require('../base-command.js') +class LifecycleCmd extends BaseCommand { + static get usage () { + return ['[-- <args>]'] } exec (args, cb) { - this.npm.commands['run-script']([this.stage, ...args], cb) + this.npm.commands['run-script']([this.constructor.name, ...args], cb) } } module.exports = LifecycleCmd |