diff options
author | isaacs <i@izs.me> | 2012-01-13 00:31:34 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-01-13 00:31:34 +0400 |
commit | 28aa53d798a3abc2c61a24401a0a1a960ae032b3 (patch) | |
tree | 206dfede5608f27e26cb1f244f08ece570085ea8 /lib/utils/read-json.js | |
parent | 7154882878bb1f2dd8a9cdba78542a2e584611e4 (diff) |
Fix #995 Optional Dependencies
Diffstat (limited to 'lib/utils/read-json.js')
-rw-r--r-- | lib/utils/read-json.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/utils/read-json.js b/lib/utils/read-json.js index ffd447d32..388d6727e 100644 --- a/lib/utils/read-json.js +++ b/lib/utils/read-json.js @@ -362,11 +362,23 @@ function processObject (opts, cb) { return function (er, json) { delete json["dev-dependencies"] } - ;["dependencies", "devDependencies"].forEach(function (d) { - json[d] = json.hasOwnProperty(d) ? depObjectify(json[d], d, json._id) : {} + ; [ "dependencies" + , "devDependencies" + , "optionalDependencies" + ].forEach(function (d) { + json[d] = json.hasOwnProperty(d) + ? depObjectify(json[d], d, json._id) + : {} + }) + + // always merge optionals into deps + Object.keys(json.optionalDependencies).forEach(function (d) { + json.dependencies[d] = json.optionalDependencies[d] }) - if (opts.dev || npm.config.get("dev") || npm.config.get("npat")) { + if (opts.dev + || npm.config.get("dev") + || npm.config.get("npat")) { // log.warn(json._id, "Adding devdeps") Object.keys(json.devDependencies || {}).forEach(function (d) { json.dependencies[d] = json.devDependencies[d] |