Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Pass a flag through to say whether it's an npat script call

  • Loading branch information...
commit bb89c5930f5969c6b6faaedfb48a08e5cbc519b8 1 parent e6173a8
isaacs isaacs authored
Showing with 14 additions and 8 deletions.
  1. +1 −1  lib/build.js
  2. +13 −7 lib/utils/lifecycle.js
2  lib/build.js
View
@@ -55,7 +55,7 @@ function build_ (global, didPre, didRB) { return function (folder, cb) {
, didPre !== build._noLC && [lifecycle, pkg, "postinstall", folder]
, didPre !== build._noLC
&& npm.config.get("npat")
- && [lifecycle, pkg, "test", folder] ]
+ && [lifecycle, pkg, "test", folder, false, false, true] ]
, cb )
})
}}
20 lib/utils/lifecycle.js
View
@@ -12,7 +12,8 @@ var log = require("./log.js")
, constants = require("constants")
, output = require("./output.js")
-function lifecycle (pkg, stage, wd, unsafe, failOk, cb) {
+function lifecycle (pkg, stage, wd, unsafe, failOk, isNpat, cb) {
+ if (typeof cb !== "function") cb = isNpat, isNpat = false
if (typeof cb !== "function") cb = failOk, failOk = false
if (typeof cb !== "function") cb = unsafe, unsafe = false
if (typeof cb !== "function") cb = wd, wd = null
@@ -42,7 +43,7 @@ function lifecycle (pkg, stage, wd, unsafe, failOk, cb) {
// even if it's never used, sh freaks out.
if (!npm.config.get("unsafe-perm")) env.TMPDIR = wd
- lifecycle_(pkg, stage, wd, env, unsafe, failOk, cb)
+ lifecycle_(pkg, stage, wd, env, unsafe, failOk, isNpat, cb)
})
}
@@ -53,7 +54,7 @@ function checkForLink (pkg, cb) {
})
}
-function lifecycle_ (pkg, stage, wd, env, unsafe, failOk, cb) {
+function lifecycle_ (pkg, stage, wd, env, unsafe, failOk, isNpat, cb) {
var PATH = []
, p = wd.split("node_modules")
, acc = path.resolve(p.shift())
@@ -87,7 +88,7 @@ function lifecycle_ (pkg, stage, wd, env, unsafe, failOk, cb) {
}
chain
- ( [ packageLifecycle && [runPackageLifecycle, pkg, env, wd, unsafe]
+ ( [ packageLifecycle && [runPackageLifecycle, pkg, env, wd, unsafe, isNpat]
, [runHookLifecycle, pkg, env, wd, unsafe] ]
, cb )
}
@@ -105,7 +106,7 @@ function validWd (d, cb) {
})
}
-function runPackageLifecycle (pkg, env, wd, unsafe, cb) {
+function runPackageLifecycle (pkg, env, wd, unsafe, isNpat, cb) {
// run package lifecycle scripts in the package root, or the nearest parent.
var stage = env.npm_lifecycle_event
, user = unsafe ? null : npm.config.get("user")
@@ -113,7 +114,7 @@ function runPackageLifecycle (pkg, env, wd, unsafe, cb) {
, cmd = env.npm_lifecycle_script
, sh = "sh"
, shFlag = "-c"
-
+
if (process.platform === "win32") {
sh = "cmd"
shFlag = "/c"
@@ -123,10 +124,15 @@ function runPackageLifecycle (pkg, env, wd, unsafe, cb) {
output.write("\n> "+pkg._id+" " + stage+" "+wd+"\n> "+cmd+"\n", function (er) {
if (er) return cb(er)
-
+
exec( sh, [shFlag, cmd], env, true, wd
, user, group
, function (er, code, stdout, stderr) {
+
+ if (isNpat) {
+ // XXX DTrejo, go nuts on this right here
+ }
+
if (er && !npm.ROLLBACK) {
log("Failed to exec "+stage+" script", pkg._id)
er.message = pkg._id + " "
Please sign in to comment.
Something went wrong with that request. Please try again.