diff options
author | isaacs <i@izs.me> | 2014-09-13 01:11:07 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2014-09-13 01:11:19 +0400 |
commit | 49b7b1cc970c32b6f8a191326fd955b13c308876 (patch) | |
tree | fdeda4a619fc00dc5fa45d5b7eb58f4f4b24f3d8 /lib | |
parent | ca791e27e97e51c1dd491bff6622ac90b54c3e23 (diff) |
lifecycle: clean up callback mutation code
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils/lifecycle.js | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/utils/lifecycle.js b/lib/utils/lifecycle.js index 204ba9a18..c0eb83dfb 100644 --- a/lib/utils/lifecycle.js +++ b/lib/utils/lifecycle.js @@ -91,24 +91,23 @@ function lifecycle_ (pkg, stage, wd, env, unsafe, failOk, cb) { env.npm_lifecycle_script = pkg.scripts[stage] } - if (failOk) { - cb = (function (cb_) { return function (er) { - if (er) log.warn("continuing anyway", er.message) - cb_() - }})(cb) - } - - if (npm.config.get("force")) { - cb = (function (cb_) { return function (er) { - if (er) log.info("forced, continuing", er) - cb_() - }})(cb) + function done (er) { + if (er) { + if (npm.config.get("force")) { + log.info("forced, continuing", er) + er = null + } else if (failOk) { + log.warn("continuing anyway", er.message) + er = null + } + } + cb(er) } chain ( [ packageLifecycle && [runPackageLifecycle, pkg, env, wd, unsafe] , [runHookLifecycle, pkg, env, wd, unsafe] ] - , cb ) + , done ) } function validWd (d, cb) { |