From e9b1c2a21dd7d666c046a321c4167b345e699528 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 26 Apr 2011 18:06:40 -0700 Subject: [PATCH] Close #843 install dev-deps locally When installing or linking at the top-level, install the devDependencies, since that's typically done in a development folder. --- lib/install.js | 1 + lib/link.js | 2 +- lib/utils/read-json.js | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/install.js b/lib/install.js index 9183d5f16a64b..6f36aa82ef9df 100644 --- a/lib/install.js +++ b/lib/install.js @@ -171,6 +171,7 @@ function install (args, cb) { if (!args.length) { if (npm.config.get("global")) args = ["."] else return readJson( path.resolve(where, "package.json") + , { dev: true } , function (er, data) { if (er) return log.er(cb, "Couldn't read dependencies.")(er) var deps = Object.keys(data.dependencies || {}) diff --git a/lib/link.js b/lib/link.js index 98ddce36640a1..f5099dc48422f 100644 --- a/lib/link.js +++ b/lib/link.js @@ -98,7 +98,7 @@ function linkPkg (folder, cb_) { var gp = npm.config.get("prefix") , me = folder || npm.prefix , readJson = require("./utils/read-json") - readJson(path.resolve(me, "package.json"), function (er, d) { + readJson(path.resolve(me, "package.json"), { dev: true }, function (er, d) { function cb (er) { return cb_(er, [[target, d && d._id]]) } diff --git a/lib/utils/read-json.js b/lib/utils/read-json.js index 1c18e7b14237c..c2bd2a0cfdadb 100644 --- a/lib/utils/read-json.js +++ b/lib/utils/read-json.js @@ -230,10 +230,12 @@ function processObject (opts, cb) { return function (er, json) { json.devDependencies = json["dev-dependencies"] delete json["dev-dependencies"] } + ;["dependencies", "devDependencies"].forEach(function (d) { json[d] = json[d] ? depObjectify(json[d]) : {} }) - if (npm.config.get("dev") || npm.config.get("npat")) { + + if (opts.dev || npm.config.get("dev") || npm.config.get("npat")) { Object.keys(json.devDependencies || {}).forEach(function (d) { json.dependencies[d] = json.devDependencies[d] })