Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: #2753 Credit: @wraithgar Close: #2753 Reviewed-by: @isaacs
- Loading branch information
Showing
7 changed files
with
20 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
module.exports = require('./utils/lifecycle-cmd.js')('restart') | ||
const npm = require('./npm.js') | ||
module.exports = require('./utils/lifecycle-cmd.js')(npm, 'restart') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
module.exports = require('./utils/lifecycle-cmd.js')('start') | ||
const npm = require('./npm.js') | ||
module.exports = require('./utils/lifecycle-cmd.js')(npm, 'start') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
module.exports = require('./utils/lifecycle-cmd.js')('stop') | ||
const npm = require('./npm.js') | ||
module.exports = require('./utils/lifecycle-cmd.js')(npm, 'stop') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters