diff options
author | Gar <gar+gh@danger.computer> | 2021-02-22 20:26:41 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2021-02-22 23:30:20 +0300 |
commit | 773ae3e7ee87b96aeb241cdde4c0c6b0f122a375 (patch) | |
tree | 3db8989736f8366f30168abe063f5ed4aebd5d79 /lib/utils | |
parent | 4e58274ed0fd2dd29d3c8d6c7c47f37a37dc0f0f (diff) |
chore(refactor): clean up lifecycle-cmds
This is a small incremental step in removing some of the complexity
surrounding the `npm` object in our code.
It moves that object one level up the chain of code, with the end goal
being that we will only require it once in the codebase, ultimately allowing
us to improve our tests.
I also changed the command that it calls to `run-script` because that is the
base command. `run` was an alias, and that is one more layer of hoops a
developer would have to jump through to find what file in `./lib` is even
being referenced here.
PR-URL: https://github.com/npm/cli/pull/2753
Credit: @wraithgar
Close: #2753
Reviewed-by: @isaacs
Diffstat (limited to 'lib/utils')
-rw-r--r-- | lib/utils/lifecycle-cmd.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/utils/lifecycle-cmd.js b/lib/utils/lifecycle-cmd.js index 40a90aa20..83a712cf4 100644 --- a/lib/utils/lifecycle-cmd.js +++ b/lib/utils/lifecycle-cmd.js @@ -1,12 +1,11 @@ // The implementation of commands that are just "run a script" // test, start, stop, restart -const npm = require('../npm.js') const usageUtil = require('./usage.js') +const completion = require('./completion/none.js') -module.exports = stage => { - const cmd = (args, cb) => npm.commands.run([stage, ...args], cb) +module.exports = (npm, stage) => { + const cmd = (args, cb) => npm.commands['run-script']([stage, ...args], cb) const usage = usageUtil(stage, `npm ${stage} [-- <args>]`) - const completion = require('./completion/none.js') return Object.assign(cmd, { usage, completion }) } |