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:
Diffstat (limited to 'lib/utils/lifecycle-cmd.js')
-rw-r--r--lib/utils/lifecycle-cmd.js21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/utils/lifecycle-cmd.js b/lib/utils/lifecycle-cmd.js
index 94b109942..8be9b5a12 100644
--- a/lib/utils/lifecycle-cmd.js
+++ b/lib/utils/lifecycle-cmd.js
@@ -1,10 +1,19 @@
// The implementation of commands that are just "run a script"
-// test, start, stop, restart
-
+// restart, start, stop, test
const usageUtil = require('./usage.js')
-module.exports = (npm, stage) => {
- const cmd = (args, cb) => npm.commands['run-script']([stage, ...args], cb)
- const usage = usageUtil(stage, `npm ${stage} [-- <args>]`)
- return Object.assign(cmd, { usage })
+class LifecycleCmd {
+ constructor (npm, stage) {
+ this.npm = npm
+ this.stage = stage
+ }
+
+ get usage () {
+ return usageUtil(this.stage, `npm ${this.stage} [-- <args>]`)
+ }
+
+ exec (args, cb) {
+ this.npm.commands['run-script']([this.stage, ...args], cb)
+ }
}
+module.exports = LifecycleCmd