aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/lib/run-script.js
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2015-03-06 02:57:32 -0600
committercjihrig <cjihrig@gmail.com>2015-03-06 11:20:05 -0500
commitfe14802fb700c5fea08b7c54f4298c3ac44a5c15 (patch)
tree74b43bf61e98f366089a416e4fe36b2f1256cd5d /deps/npm/lib/run-script.js
parentc09c90c1a9e74ee4f29a051daf10bc4c5d5f7755 (diff)
downloadandroid-node-v8-fe14802fb700c5fea08b7c54f4298c3ac44a5c15.tar.gz
android-node-v8-fe14802fb700c5fea08b7c54f4298c3ac44a5c15.tar.bz2
android-node-v8-fe14802fb700c5fea08b7c54f4298c3ac44a5c15.zip
deps: upgrade npm to 2.7.0
PR-URL: https://github.com/iojs/io.js/pull/1080 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/npm/lib/run-script.js')
-rw-r--r--deps/npm/lib/run-script.js49
1 files changed, 38 insertions, 11 deletions
diff --git a/deps/npm/lib/run-script.js b/deps/npm/lib/run-script.js
index ce8ea0f13a..b6aa5fe7e8 100644
--- a/deps/npm/lib/run-script.js
+++ b/deps/npm/lib/run-script.js
@@ -84,31 +84,56 @@ function runScript (args, cb) {
function list(cb) {
var json = path.join(npm.localPrefix, "package.json")
+ var cmdList = [ "publish", "install", "uninstall"
+ , "test", "stop", "start", "restart"
+ ].reduce(function (l, p) {
+ return l.concat(["pre" + p, p, "post" + p])
+ }, [])
return readJson(json, function(er, d) {
if (er && er.code !== "ENOENT" && er.code !== "ENOTDIR") return cb(er)
if (er) d = {}
- var scripts = Object.keys(d.scripts || {})
+ var allScripts = Object.keys(d.scripts || {})
+ var scripts = []
+ var runScripts = []
+ allScripts.forEach(function (script) {
+ if (cmdList.indexOf(script) !== -1) scripts.push(script)
+ else runScripts.push(script)
+ })
if (log.level === "silent") {
- return cb(null, scripts)
+ return cb(null, allScripts)
}
if (npm.config.get("json")) {
console.log(JSON.stringify(d.scripts || {}, null, 2))
- return cb(null, scripts)
+ return cb(null, allScripts)
+ }
+
+ if (npm.config.get("parseable")) {
+ allScripts.forEach(function(script) {
+ console.log(script + ":" + d.scripts[script])
+ })
+ return cb(null, allScripts)
}
- var s = ":"
- var prefix = ""
- if (!npm.config.get("parseable")) {
- s = "\n "
- prefix = " "
- console.log("Available scripts in the %s package:", d.name)
+ var s = "\n "
+ var prefix = " "
+ if (scripts.length) {
+ console.log("Lifecycle scripts included in %s:", d.name)
}
scripts.forEach(function(script) {
console.log(prefix + script + s + d.scripts[script])
})
- return cb(null, scripts)
+ if (!scripts.length && runScripts.length) {
+ console.log("Scripts available in %s via `npm run-script`:", d.name)
+ }
+ else if (runScripts.length) {
+ console.log("\navailable via `npm run-script`:")
+ }
+ runScripts.forEach(function(script) {
+ console.log(prefix + script + s + d.scripts[script])
+ })
+ return cb(null, allScripts)
})
}
@@ -116,7 +141,7 @@ function run (pkg, wd, cmd, args, cb) {
if (!pkg.scripts) pkg.scripts = {}
var cmds
- if (cmd === "restart") {
+ if (cmd === "restart" && !pkg.scripts.restart) {
cmds = [
"prestop", "stop", "poststop",
"restart",
@@ -134,6 +159,8 @@ function run (pkg, wd, cmd, args, cb) {
log.verbose("run-script using default platform env: env (Unix)")
pkg.scripts[cmd] = "env"
}
+ } else if (npm.config.get("if-present")) {
+ return cb(null);
} else {
return cb(new Error("missing script: " + cmd))
}