Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-01-13 00:31:34 +0400
committerisaacs <i@izs.me>2012-01-13 00:31:34 +0400
commit28aa53d798a3abc2c61a24401a0a1a960ae032b3 (patch)
tree206dfede5608f27e26cb1f244f08ece570085ea8 /lib/utils/read-json.js
parent7154882878bb1f2dd8a9cdba78542a2e584611e4 (diff)
Fix #995 Optional Dependencies
Diffstat (limited to 'lib/utils/read-json.js')
-rw-r--r--lib/utils/read-json.js18
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]