diff options
author | Tim Oxley <secoif@gmail.com> | 2014-01-08 14:16:15 +0400 |
---|---|---|
committer | Tim Oxley <secoif@gmail.com> | 2014-05-10 21:55:03 +0400 |
commit | cb295989c38494fb1190e1bcf05683a38bbd37fc (patch) | |
tree | d3539f3d05499d1fd76a892818a1cef901989e52 | |
parent | 86f5496fc9d0f88ae3b9ebfe5eb0bc686b0384b6 (diff) |
Ensure only matching deps update with update --save*
Issue #4438
-rw-r--r-- | lib/outdated.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/outdated.js b/lib/outdated.js index fd409bd59..c053ddeea 100644 --- a/lib/outdated.js +++ b/lib/outdated.js @@ -155,12 +155,29 @@ function outdated_ (args, dir, parentHas, depth, cb) { } var deps = null readJson(path.resolve(dir, "package.json"), function (er, d) { + d = d || {} if (er && er.code !== "ENOENT" && er.code !== "ENOTDIR") return cb(er) deps = (er) ? true : (d.dependencies || {}) + + if (npm.config.get("save-dev")) { + deps = d.devDependencies || {} + return next() + } + + if (npm.config.get("save")) { + return next() + } + + if (npm.config.get("save-optional")) { + deps = d.optionalDependencies || {} + return next() + } + var doUpdate = npm.config.get("dev") || (!npm.config.get("production") && !Object.keys(parentHas).length && !npm.config.get("global")) + if (!er && d && doUpdate) { Object.keys(d.devDependencies || {}).forEach(function (k) { if (!(k in parentHas)) { |