diff options
author | Rebecca Turner <me@re-becca.org> | 2015-06-15 22:52:10 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2015-06-26 03:27:17 +0300 |
commit | b0eca367f4f73034b20a602df1c61cf6d9327b34 (patch) | |
tree | cb952e8c958706b0b062dadb525f5ee83f5963bc | |
parent | ab151a44da6f92ec9d5c399a78ea07b7b9bd0603 (diff) |
outdated: Compute missing dev deps in addition to missing deps
-rw-r--r-- | lib/install/deps.js | 3 | ||||
-rw-r--r-- | lib/install/node.js | 1 | ||||
-rw-r--r-- | lib/outdated.js | 31 |
3 files changed, 32 insertions, 3 deletions
diff --git a/lib/install/deps.js b/lib/install/deps.js index 27dd0bca1..abcf7bc70 100644 --- a/lib/install/deps.js +++ b/lib/install/deps.js @@ -77,6 +77,9 @@ var recalculateMetadata = exports.recalculateMetadata = function (tree, log, nex } else if (tree.package.dependencies[req.name] != null) { tree.missingDeps[req.name] = req.rawSpec done() + } else if (tree.package.devDependencies[req.name] != null) { + tree.missingDevDeps[req.name] = req.rawSpec + done() } else { done() } diff --git a/lib/install/node.js b/lib/install/node.js index 0e4f205a6..38328e88e 100644 --- a/lib/install/node.js +++ b/lib/install/node.js @@ -12,6 +12,7 @@ var defaultTemplate = { children: [], requiredBy: [], missingDeps: {}, + missingDevDeps: {}, path: null, realpath: null } diff --git a/lib/outdated.js b/lib/outdated.js index 4e7ca66f4..a640a32c7 100644 --- a/lib/outdated.js +++ b/lib/outdated.js @@ -224,6 +224,11 @@ function outdated_ (args, path, tree, parentHas, depth, cb) { var pkg = tree.package var deps = tree.children.filter(function(child){ return !isExtraneous(child) }) || [] + + deps.forEach(function (dep) { + types[dep.package.name] = 'dependencies' + }) + Object.keys(tree.missingDeps).forEach(function (name) { deps.push({ package: { name: name }, @@ -231,11 +236,31 @@ function outdated_ (args, path, tree, parentHas, depth, cb) { parent: tree, isMissing: true }) + types[name] = 'dependencies' }) - deps.forEach(function (dep) { - types[dep.package.name] = 'dependencies' - }) + // If we explicitly asked for dev deps OR we didn't ask for production deps + // AND we asked to save dev-deps OR we didn't ask to save anything that's NOT + // dev deps then… + // (All the save checking here is because this gets called from npm-update currently + // and that requires this logic around dev deps.) + // FIXME: Refactor npm update to not be in terms of outdated. + if ((npm.config.get('dev') || !npm.config.get('production')) && + (npm.config.get('save-dev') || ( + !npm.config.get('save') && !npm.config.get('save-optional')))) { + Object.keys(tree.missingDevDeps).forEach(function (name) { + deps.push({ + package: { name: name }, + path: tree.path, + parent: tree, + isMissing: true + }) + if (!types[name]) { + types[name] = 'devDependencies' + } + }) + } + if (npm.config.get('save-dev')) { deps = deps.filter(function (dep) { return pkg.devDependencies[dep.package.name] }) deps.forEach(function (dep) { |