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/rebuild.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/rebuild.js')
-rw-r--r-- | lib/rebuild.js | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/rebuild.js b/lib/rebuild.js index 53bd95cff..0e36c6361 100644 --- a/lib/rebuild.js +++ b/lib/rebuild.js @@ -1,27 +1,27 @@ module.exports = rebuild -var readInstalled = require("read-installed") - , semver = require("semver") - , log = require("npmlog") - , npm = require("./npm.js") - , npa = require("npm-package-arg") +var readInstalled = require('read-installed') +var semver = require('semver') +var log = require('npmlog') +var npm = require('./npm.js') +var npa = require('npm-package-arg') -rebuild.usage = "npm rebuild [[<@scope>/<name>]...]" +rebuild.usage = 'npm rebuild [[<@scope>/<name>]...]' -rebuild.completion = require("./utils/completion/installed-deep.js") +rebuild.completion = require('./utils/completion/installed-deep.js') function rebuild (args, cb) { - var opt = { depth: npm.config.get("depth"), dev: true } + var opt = { depth: npm.config.get('depth'), dev: true } readInstalled(npm.prefix, opt, function (er, data) { - log.info("readInstalled", typeof data) + log.info('readInstalled', typeof data) if (er) return cb(er) var set = filter(data, args) - , folders = Object.keys(set).filter(function (f) { - return f !== npm.prefix - }) + var folders = Object.keys(set).filter(function (f) { + return f !== npm.prefix + }) if (!folders.length) return cb() - log.silly("rebuild set", folders) + log.silly('rebuild set', folders) cleanBuild(folders, set, cb) }) } @@ -31,8 +31,8 @@ function cleanBuild (folders, set, cb) { if (er) return cb(er) log.clearProgress() console.log(folders.map(function (f) { - return set[f] + " " + f - }).join("\n")) + return set[f] + ' ' + f + }).join('\n')) log.showProgress() cb() }) @@ -47,11 +47,11 @@ function filter (data, args, set, seen) { var pass if (!args.length) pass = true // rebuild everything else if (data.name && data._id) { - for (var i = 0, l = args.length; i < l; i ++) { + for (var i = 0, l = args.length; i < l; i++) { var arg = args[i] - , nv = npa(arg) - , n = nv.name - , v = nv.rawSpec + var nv = npa(arg) + var n = nv.name + var v = nv.rawSpec if (n !== data.name) continue if (!semver.satisfies(data.version, v, true)) continue pass = true @@ -59,7 +59,7 @@ function filter (data, args, set, seen) { } } if (pass && data._id) { - log.verbose("rebuild", "path, id", [data.path, data._id]) + log.verbose('rebuild', 'path, id', [data.path, data._id]) set[data.path] = data._id } // need to also dive through kids, always. @@ -68,7 +68,7 @@ function filter (data, args, set, seen) { Object.keys(data.dependencies || {}).forEach(function (d) { // return var dep = data.dependencies[d] - if (typeof dep === "string") return + if (typeof dep === 'string') return filter(dep, args, set, seen) }) return set |