diff options
author | Elan Shanker <elan.shanker@gmail.com> | 2013-08-25 08:07:35 +0400 |
---|---|---|
committer | Domenic Denicola <domenic@domenicdenicola.com> | 2013-08-25 20:38:19 +0400 |
commit | f65da7d7f156fd28db10042a8db6682ef70178a7 (patch) | |
tree | c7bc0c1d9f53c987a4ac177726d8124ab420d9dc | |
parent | ec82299a6cfb8df005e93bd33ceb8b206494467b (diff) |
prune: --production option to unbuild devDependencies
Closes #2854.
-rw-r--r-- | lib/prune.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/prune.js b/lib/prune.js index 0e13da13b..dbe8790b9 100644 --- a/lib/prune.js +++ b/lib/prune.js @@ -13,19 +13,19 @@ var readInstalled = require("read-installed") prune.completion = require("./utils/completion/installed-deep.js") function prune (args, cb) { - //check if is a valid package.json file var jsonFile = path.resolve(npm.dir, "..", "package.json" ) - readJson(jsonFile, log.warn, function (er, data) { + readJson(jsonFile, log.warn, function (er, packageData) { if (er) return cb(er) - next() - }) - - function next() { readInstalled(npm.prefix, npm.config.get("depth"), function (er, data) { if (er) return cb(er) + if (npm.config.get("production")) { + Object.keys(packageData.devDependencies || {}).forEach(function (k) { + if (data.dependencies[k]) data.dependencies[k].extraneous = true + }) + } prune_(args, data, cb) }) - } + }) } function prune_ (args, data, cb) { |