diff --git a/lib/run-script.js b/lib/run-script.js index ce8ea0f13a7..e96439859f8 100644 --- a/lib/run-script.js +++ b/lib/run-script.js @@ -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") { diff --git a/test/tap/run-script.js b/test/tap/run-script.js index 6b5ce26aa48..d7681b9acc4 100644 --- a/test/tap/run-script.js +++ b/test/tap/run-script.js @@ -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() diff --git a/test/tap/run-script/package.json b/test/tap/run-script/package.json index ebaffefe029..761b15ffb9b 100644 --- a/test/tap/run-script/package.json +++ b/test/tap/run-script/package.json @@ -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')\"" } }