From 773ae3e7ee87b96aeb241cdde4c0c6b0f122a375 Mon Sep 17 00:00:00 2001 From: Gar Date: Mon, 22 Feb 2021 09:26:41 -0800 Subject: 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 --- lib/utils/lifecycle-cmd.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/utils') 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} [-- ]`) - const completion = require('./completion/none.js') return Object.assign(cmd, { usage, completion }) } -- cgit v1.2.3