diff options
author | Rebecca Turner <me@re-becca.org> | 2015-10-07 01:45:41 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2015-10-09 02:24:32 +0300 |
commit | b78fec9dac12176f29618c783aaf231a2c767b54 (patch) | |
tree | bdd2301f9740ed197dd54e6fd1d65ec24d21c5da /lib/outdated.js | |
parent | 2289234e11b30c878585aebee68d4a3a5bd63cce (diff) |
module-name: Factor out module name reading
Bring consistent guarding against null/undefined and consistent
business logic.
PR-URL: //github.com/npm/npm/pull/9890
Fixes: #9766
Diffstat (limited to 'lib/outdated.js')
-rw-r--r-- | lib/outdated.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/outdated.js b/lib/outdated.js index 61eb3beb9..40506f2af 100644 --- a/lib/outdated.js +++ b/lib/outdated.js @@ -39,6 +39,7 @@ var long = npm.config.get('long') var mapToRegistry = require('./utils/map-to-registry.js') var isExtraneous = require('./install/is-extraneous.js') var recalculateMetadata = require('./install/deps.js').recalculateMetadata +var moduleName = require('./utils/module-name.js') function uniqName (item) { return item[0].path + '|' + item[1] + '|' + item[7] @@ -212,7 +213,7 @@ function outdated_ (args, path, tree, parentHas, depth, cb) { var deps = tree.children.filter(function (child) { return !isExtraneous(child) }) || [] deps.forEach(function (dep) { - types[dep.package.name] = 'dependencies' + types[moduleName(dep)] = 'dependencies' }) Object.keys(tree.missingDeps).forEach(function (name) { @@ -250,17 +251,17 @@ function outdated_ (args, path, tree, parentHas, depth, cb) { } if (npm.config.get('save-dev')) { - deps = deps.filter(function (dep) { return pkg.devDependencies[dep.package.name] }) + deps = deps.filter(function (dep) { return pkg.devDependencies[moduleName(dep)] }) deps.forEach(function (dep) { - types[dep.package.name] = 'devDependencies' + types[moduleName(dep)] = 'devDependencies' }) } else if (npm.config.get('save')) { // remove optional dependencies from dependencies during --save. - deps = deps.filter(function (dep) { return !pkg.optionalDependencies[dep.package.name] }) + deps = deps.filter(function (dep) { return !pkg.optionalDependencies[moduleName(dep)] }) } else if (npm.config.get('save-optional')) { - deps = deps.filter(function (dep) { return pkg.optionalDependencies[dep.package.name] }) + deps = deps.filter(function (dep) { return pkg.optionalDependencies[moduleName(dep)] }) deps.forEach(function (dep) { - types[dep.package.name] = 'optionalDependencies' + types[moduleName(dep)] = 'optionalDependencies' }) } var doUpdate = dev || ( @@ -292,7 +293,7 @@ function outdated_ (args, path, tree, parentHas, depth, cb) { // if has[dep] !== shouldHave[dep], then cb with the data // otherwise dive into the folder asyncMap(deps, function (dep, cb) { - var name = dep.package.name + var name = moduleName(dep) var required = (tree.package.dependencies)[name] || (tree.package.optionalDependencies)[name] || (tree.package.devDependencies)[name] || |