diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2015-06-23 08:18:52 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2015-06-26 03:27:33 +0300 |
commit | b50be6aff34a739ca43de65f546e743d1a9975b9 (patch) | |
tree | 3153fd3a271245b8a05a9be196286fbe31fc9d44 /lib/outdated.js | |
parent | 7c5ebe0552b7b5d0cdca34d28c4f16fe794ff2ff (diff) |
src: make the npm source comply with `standard`
This is a huge set of mostly mechanical changes. Going forward, all
changes to the npm source base are expected to comply with `standard`,
and it's been integrated into the test suite to enforce that. There are
a few notes below about specific classes of changes that need to be
handled specially for npm's code base.
standard: "Expected error to be handled."
`standard` only expects errors spelled "err" to be handled.
`npm-registry-mock` never actually invokes its callback with an error,
so in some cases I just changed it to be spelled "er" and called it
good.
standard: "Expected a "break" statement before 'case'."
This behavior is actually on purpose, and I don't feel like rewriting
the affected code right now (or, you know, ever). So I added code
comments disabling the checks in the three applicable changes.
standard: "x is a function."
Rebinding functions created via declarations (as opposed to expressions)
is a no-no?
PR-URL: https://github.com/npm/npm/pull/8668
Diffstat (limited to 'lib/outdated.js')
-rw-r--r-- | lib/outdated.js | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/lib/outdated.js b/lib/outdated.js index 7ac4a9548..011a3dbbb 100644 --- a/lib/outdated.js +++ b/lib/outdated.js @@ -16,7 +16,7 @@ packages. module.exports = outdated -outdated.usage = "npm outdated [[<@scope>/]<pkg> ...]" +outdated.usage = 'npm outdated [[<@scope>/]<pkg> ...]' outdated.completion = require('./utils/completion/installed-deep.js') @@ -154,20 +154,6 @@ function ansiTrim (str) { return str.replace(r, '') } -function depToPrettyLocation (dep) { - var depname = dep.package.name - var parentLocation - - if (dep.requiredBy && dep.requiredBy.length > 1) { - parentLocation = '[ ' + dep.requiredBy.map(function (parent) { - return depToPrettyLocation(parent) - }).join(', ') + ' ]' - } else if (dep.requiredBy && dep.requiredBy.length) { - parentLocation = depToPrettyLocation(dep.requiredBy[0]) - } - return parentLocation ? parentLocation + ' > ' + depname : depname -} - function makeParseable (list) { return list.map(function (p) { var dep = p[0] @@ -223,7 +209,7 @@ function outdated_ (args, path, tree, parentHas, depth, cb) { var types = {} var pkg = tree.package - var deps = tree.children.filter(function(child){ return !isExtraneous(child) }) || [] + var deps = tree.children.filter(function (child) { return !isExtraneous(child) }) || [] deps.forEach(function (dep) { types[dep.package.name] = 'dependencies' @@ -275,16 +261,16 @@ function outdated_ (args, path, tree, parentHas, depth, cb) { types[dep.package.name] = 'optionalDependencies' }) } - var doUpdate = npm.config.get("dev") || ( - !npm.config.get("production") && + var doUpdate = npm.config.get('dev') || ( + !npm.config.get('production') && !Object.keys(parentHas).length && - !npm.config.get("global") + !npm.config.get('global') ) if (doUpdate) { Object.keys(pkg.devDependencies).forEach(function (k) { if (!(k in parentHas)) { deps[k] = pkg.devDependencies[k] - types[k] = "devDependencies" + types[k] = 'devDependencies' } }) } @@ -422,9 +408,10 @@ function shouldUpdate (args, tree, dep, has, req, depth, pkgpath, cb, type) { var dFromUrl = d._from && url.parse(d._from).protocol var cFromUrl = curr && curr.from && url.parse(curr.from).protocol - if (!curr || dFromUrl && cFromUrl && d._from !== curr.from - || d.version !== curr.version - || d.version !== l.version) { + if (!curr || + dFromUrl && cFromUrl && d._from !== curr.from || + d.version !== curr.version || + d.version !== l.version) { if (parsed.type === 'local') return updateLocalDeps(l.version) doIt(d.version, l.version) |