Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
run-script: only run restart lifecyle when no script
Browse files Browse the repository at this point in the history
Fixes #1999, #2716.
  • Loading branch information
watilde authored and othiym23 committed Feb 27, 2015
1 parent 13b4121 commit 2f6a1df
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 4 additions & 6 deletions lib/run-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,10 @@ function run (pkg, wd, cmd, args, cb) {
if (!pkg.scripts) pkg.scripts = {}

var cmds
if (cmd === "restart") {
cmds = [
"prestop", "stop", "poststop",
"restart",
"prestart", "start", "poststart"
]
if (cmd === "restart" && !pkg.scripts.restart) {
cmds = [ "prestop", "stop", "poststop"
, "prestart", "start", "poststart"
]
} else {
if (!pkg.scripts[cmd]) {
if (cmd === "test") {
Expand Down
4 changes: 4 additions & 0 deletions test/tap/run-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ test("npm run-script nonexistent-script", function (t) {
})
})

test("npm run-script restart when there isn't restart", function (t) {
common.npm(["run-script", "restart"], opts, testOutput.bind(null, t, "stop;start"))
})

test("cleanup", function (t) {
cleanup()
t.end()
Expand Down
3 changes: 2 additions & 1 deletion test/tap/run-script/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"postwith-post":"node -e \"console.log(process.argv[1] || 'post')\"",
"prewith-both":"node -e \"console.log(process.argv[1] || 'pre')\"",
"with-both":"node -e \"console.log(process.argv[1] || 'main')\"",
"postwith-both":"node -e \"console.log(process.argv[1] || 'post')\""
"postwith-both":"node -e \"console.log(process.argv[1] || 'post')\"",
"stop":"node -e \"console.log(process.argv[1] || 'stop')\""
}
}

0 comments on commit 2f6a1df

Please sign in to comment.