diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2014-05-24 10:42:13 +0400 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2014-06-13 23:41:13 +0400 |
commit | 1c2938189122c0640b9403746a6bfed4d6142b27 (patch) | |
tree | 8c6c5776818acc47454bb514f58623f05f8f486a /lib | |
parent | 626c3e4a7fb37159b79ab9b3af2c030f26540b0f (diff) |
remove dead code and fix jshint warnings
Diffstat (limited to 'lib')
-rw-r--r-- | lib/adduser.js | 1 | ||||
-rw-r--r-- | lib/build.js | 4 | ||||
-rw-r--r-- | lib/completion.js | 11 | ||||
-rw-r--r-- | lib/config.js | 6 | ||||
-rw-r--r-- | lib/dedupe.js | 10 | ||||
-rw-r--r-- | lib/docs.js | 11 | ||||
-rw-r--r-- | lib/edit.js | 1 | ||||
-rw-r--r-- | lib/help-search.js | 34 | ||||
-rw-r--r-- | lib/help.js | 14 | ||||
-rw-r--r-- | lib/install.js | 14 | ||||
-rw-r--r-- | lib/link.js | 2 | ||||
-rw-r--r-- | lib/ls.js | 12 | ||||
-rw-r--r-- | lib/npm.js | 3 | ||||
-rw-r--r-- | lib/outdated.js | 6 | ||||
-rw-r--r-- | lib/prune.js | 2 | ||||
-rw-r--r-- | lib/publish.js | 2 | ||||
-rw-r--r-- | lib/rebuild.js | 3 | ||||
-rw-r--r-- | lib/repo.js | 1 | ||||
-rw-r--r-- | lib/run-script.js | 2 | ||||
-rw-r--r-- | lib/search.js | 10 | ||||
-rw-r--r-- | lib/shrinkwrap.js | 3 | ||||
-rw-r--r-- | lib/submodule.js | 2 | ||||
-rw-r--r-- | lib/test.js | 1 | ||||
-rw-r--r-- | lib/unbuild.js | 7 | ||||
-rw-r--r-- | lib/uninstall.js | 5 | ||||
-rw-r--r-- | lib/unpublish.js | 2 | ||||
-rw-r--r-- | lib/update.js | 1 | ||||
-rw-r--r-- | lib/version.js | 2 | ||||
-rw-r--r-- | lib/view.js | 10 | ||||
-rw-r--r-- | lib/whoami.js | 2 | ||||
-rw-r--r-- | lib/xmas.js | 17 |
31 files changed, 73 insertions, 128 deletions
diff --git a/lib/adduser.js b/lib/adduser.js index 84667a360..579ecb0a9 100644 --- a/lib/adduser.js +++ b/lib/adduser.js @@ -23,7 +23,6 @@ function adduser (args, cb) { , p : npm.config.get("_password") || "" , e : npm.config.get("email") || "" } - , changed = false , u = {} , fns = [readUsername, readPassword, readEmail, save] diff --git a/lib/build.js b/lib/build.js index 4b73c1e27..350774a45 100644 --- a/lib/build.js +++ b/lib/build.js @@ -77,7 +77,6 @@ function linkStuff (pkg, folder, global, didRB, cb) { // otherwise, then bins are in folder/../.bin var parent = path.dirname(folder) , gnm = global && npm.globalDir - , top = parent === npm.dir , gtop = parent === gnm log.verbose("linkStuff", [global, gnm, gtop, parent]) @@ -150,7 +149,7 @@ function rebuildBundles (pkg, folder, parent, gtop, cb) { if (build._didBuild[file]) return cb() log.verbose("rebuild bundle", file) // if file is not a package dir, then don't do it. - fs.lstat(path.resolve(file, "package.json"), function (er, st) { + fs.lstat(path.resolve(file, "package.json"), function (er) { if (er) return cb() build_(false)(file, cb) }) @@ -219,7 +218,6 @@ function linkMans (pkg, folder, parent, gtop, cb) { var parseMan = man.match(/(.*\.([0-9]+)(\.gz)?)$/) , stem = parseMan[1] , sxn = parseMan[2] - , gz = parseMan[3] || "" , bn = path.basename(stem) , manDest = path.join(manRoot, "man" + sxn, bn) diff --git a/lib/completion.js b/lib/completion.js index 0e56d043f..5c1098a59 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -26,12 +26,11 @@ completion.completion = function (opts, cb) { , path = require("path") , bashExists = null , zshExists = null - , bashProfExists = null - fs.stat(path.resolve(process.env.HOME, ".bashrc"), function (er, b) { + fs.stat(path.resolve(process.env.HOME, ".bashrc"), function (er) { bashExists = !er next() }) - fs.stat(path.resolve(process.env.HOME, ".zshrc"), function (er, b) { + fs.stat(path.resolve(process.env.HOME, ".zshrc"), function (er) { zshExists = !er next() }) @@ -79,7 +78,6 @@ function completion (args, cb) { , word = words[w] , line = process.env.COMP_LINE , point = +process.env.COMP_POINT - , lineLength = line.length , partialLine = line.substr(0, point) , partialWords = words.slice(0, w) @@ -159,7 +157,7 @@ function dumpScript (cb) { if (er) return cb(er) d = d.replace(/^\#\!.*?\n/, "") - process.stdout.write(d, function (n) { cb() }) + process.stdout.write(d, function () { cb() }) process.stdout.on("error", function (er) { // Darwin is a real dick sometimes. // @@ -218,8 +216,6 @@ function configCompl (opts, cb) { , split = word.match(/^(-+)((?:no-)*)(.*)$/) , dashes = split[1] , no = split[2] - , conf = split[3] - , confs = allConfs , flags = configNames.filter(isFlag) console.error(flags) @@ -241,7 +237,6 @@ function configValueCompl (opts, cb) { function isFlag (word) { // shorthands never take args. var split = word.match(/^(-*)((?:no-)+)?(.*)$/) - , dashes = split[1] , no = split[2] , conf = split[3] return no || configTypes[conf] === Boolean || shorthands[conf] diff --git a/lib/config.js b/lib/config.js index 7d9776379..8dc814acd 100644 --- a/lib/config.js +++ b/lib/config.js @@ -11,7 +11,6 @@ config.usage = "npm config set <key> <value>" var log = require("npmlog") , npm = require("./npm.js") - , spawn = require("child_process").spawn , fs = require("graceful-fs") , npmconf = require("npmconf") , types = npmconf.defs.types @@ -150,10 +149,6 @@ function sort (a, b) { return a > b ? 1 : -1 } -function reverse (a, b) { - return a > b ? -1 : 1 -} - function public (k) { return !(k.charAt(0) === "_" || types[k] !== types[k]) } @@ -236,7 +231,6 @@ function list (cb) { , bpath = builtin.path , bconfKeys = getKeys(bconf) if (bconfKeys.length) { - var path = require("path") msg += "; builtin config " + bpath + "\n" bconfKeys.forEach(function (k) { var val = (k.charAt(0) === "_") diff --git a/lib/dedupe.js b/lib/dedupe.js index 1b3090a5e..e6762e15b 100644 --- a/lib/dedupe.js +++ b/lib/dedupe.js @@ -12,10 +12,6 @@ var fs = require("fs") var asyncMap = require("slide").asyncMap var path = require("path") var readJson = require("read-package-json") -var archy = require("archy") -var util = require("util") -var RegClient = require("npm-registry-client") -var npmconf = require("npmconf") var semver = require("semver") var rm = require("./utils/gently-rm.js") var log = require("npmlog") @@ -94,7 +90,6 @@ function dedupe_ (dir, filter, unavoidable, dryrun, silent, cb) { })] })] }).map(function (item) { - var name = item[0] var set = item[1] var ranges = set.map(function (i) { @@ -138,7 +133,6 @@ function dedupe_ (dir, filter, unavoidable, dryrun, silent, cb) { b.pop() // find the longest chain that both A and B share. // then push the name back on it, and join by /node_modules/ - var res = [] for (var i = 0, al = a.length, bl = b.length; i < al && i < bl && a[i] === b[i]; i++); return a.slice(0, i).concat(name).join(path.sep + "node_modules" + path.sep) }) : undefined @@ -205,9 +199,9 @@ function installAndRetest (set, filter, dir, unavoidable, silent, cb) { // hrm? return cb(new Error("danger zone\n" + name + " " + - + regMatch + " " + locMatch)) + regMatch + " " + locMatch)) - }, function (er, installed) { + }, function (er) { if (er) return cb(er) asyncMap(remove, rm, function (er) { if (er) return cb(er) diff --git a/lib/docs.js b/lib/docs.js index 8e19aa056..77073fbb9 100644 --- a/lib/docs.js +++ b/lib/docs.js @@ -15,8 +15,8 @@ var url_ = require("url") , npm = require("./npm.js") , registry = npm.registry , opener = require("opener") - , path = require('path') - , log = require('npmlog') + , path = require("path") + , log = require("npmlog") function url (json) { return json.homepage ? json.homepage : "https://npmjs.org/package/" + json.name @@ -28,7 +28,9 @@ function docs (args, cb) { if (!pending) return getDoc('.', cb) args.forEach(function(proj) { getDoc(proj, function(err) { - if (err) return cb(err) + if (err) { + return cb(err) + } --pending || cb() }) }) @@ -39,8 +41,9 @@ function getDoc (project, cb) { var package = path.resolve(process.cwd(), "package.json") if (project === '.' || project === './') { + var json try { - var json = require(package) + json = require(package) if (!json.name) throw new Error('package.json does not have a valid "name" property') project = json.name } catch (e) { diff --git a/lib/edit.js b/lib/edit.js index 791dc60cf..ddf501d54 100644 --- a/lib/edit.js +++ b/lib/edit.js @@ -7,7 +7,6 @@ edit.usage = "npm edit <pkg>" edit.completion = require("./utils/completion/installed-shallow.js") var npm = require("./npm.js") - , spawn = require("child_process").spawn , path = require("path") , fs = require("graceful-fs") , editor = require("editor") diff --git a/lib/help-search.js b/lib/help-search.js index 027f14c42..3b3fe1189 100644 --- a/lib/help-search.js +++ b/lib/help-search.js @@ -4,9 +4,6 @@ module.exports = helpSearch var fs = require("graceful-fs") , path = require("path") , asyncMap = require("slide").asyncMap - , cliDocsPath = path.join(__dirname, "..", "doc", "cli") - , apiDocsPath = path.join(__dirname, "..", "doc", "api") - , log = require("npmlog") , npm = require("./npm.js") , glob = require("glob") @@ -16,9 +13,6 @@ function helpSearch (args, silent, cb) { if (typeof cb !== "function") cb = silent, silent = false if (!args.length) return cb(helpSearch.usage) - // see if we're actually searching the api docs. - var argv = npm.config.get("argv").cooked - var docPath = path.resolve(__dirname, "..", "doc") return glob(docPath + "/*/*.md", function (er, files) { if (er) @@ -53,24 +47,27 @@ function searchFiles (args, files, cb) { var data = files[file] // skip if no matches at all + var match for (var a = 0, l = args.length; a < l && !match; a++) { - var match = data.toLowerCase().indexOf(args[a].toLowerCase()) !== -1 + match = data.toLowerCase().indexOf(args[a].toLowerCase()) !== -1 } if (!match) return var lines = data.split(/\n+/) - var context = [] // if a line has a search term, then skip it and the next line. // if the next line has a search term, then skip all 3 // otherwise, set the line to null. then remove the nulls. - for (var i = 0, l = lines.length; i < l; i ++) { + l = lines.length + for (var i = 0; i < l; i ++) { var line = lines[i] , nextLine = lines[i + 1] - , match = false + , ll + + match = false if (nextLine) { - for (var a = 0, ll = args.length; a < ll && !match; a ++) { + for (a = 0, ll = args.length; a < ll && !match; a ++) { match = nextLine.toLowerCase() .indexOf(args[a].toLowerCase()) !== -1 } @@ -82,7 +79,7 @@ function searchFiles (args, files, cb) { } match = false - for (var a = 0, ll = args.length; a < ll && !match; a ++) { + for (a = 0, ll = args.length; a < ll && !match; a ++) { match = line.toLowerCase().indexOf(args[a].toLowerCase()) !== -1 } if (match) { @@ -161,7 +158,7 @@ function formatResults (args, results, cb) { var cols = Math.min(process.stdout.columns || Infinity, 80) + 1 - var out = results.map(function (res, i, results) { + var out = results.map(function (res) { var out = res.cmd , r = Object.keys(res.hits).map(function (k) { return k + ":" + res.hits[k] @@ -174,7 +171,7 @@ function formatResults (args, results, cb) { if (!npm.config.get("long")) return out - var out = "\n\n" + out + out = "\n\n" + out + "\n" + (new Array(cols)).join("—") + "\n" + res.lines.map(function (line, i) { if (line === null || i > 3) return "" @@ -191,12 +188,11 @@ function formatResults (args, results, cb) { }) out = newOut.join("") } + var color = "" + , reset = "" if (npm.color) { - var color = "\033[31;40m" - , reset = "\033[0m" - } else { - var color = "" - , reset = "" + color = "\033[31;40m" + reset = "\033[0m" } out = out.split("\1").join(color) .split("\2").join(reset) diff --git a/lib/help.js b/lib/help.js index c68f322ab..8f54d69de 100644 --- a/lib/help.js +++ b/lib/help.js @@ -6,8 +6,7 @@ help.completion = function (opts, cb) { getSections(cb) } -var fs = require("graceful-fs") - , path = require("path") +var path = require("path") , spawn = require("child_process").spawn , npm = require("./npm.js") , log = require("npmlog") @@ -58,7 +57,6 @@ function help (args, cb) { // npm help <section>: Try to find the path var manroot = path.resolve(__dirname, "..", "man") - var htmlroot = path.resolve(__dirname, "..", "html", "doc") // legacy if (section === "global") @@ -109,10 +107,11 @@ function viewMan (man, cb) { env.MANPATH = manpath var viewer = npm.config.get("viewer") + var conf switch (viewer) { case "woman": var a = ["-e", "(woman-find-file \"" + man + "\")"] - var conf = { env: env, customFds: [ 0, 1, 2] } + conf = { env: env, customFds: [ 0, 1, 2] } var woman = spawn("emacsclient", a, conf) woman.on("close", cb) break @@ -122,9 +121,9 @@ function viewMan (man, cb) { break default: - var conf = { env: env, customFds: [ 0, 1, 2] } - var man = spawn("man", [num, section], conf) - man.on("close", cb) + conf = { env: env, customFds: [ 0, 1, 2] } + var manProcess = spawn("man", [num, section], conf) + manProcess.on("close", cb) break } } @@ -193,7 +192,6 @@ function usages () { + (usage.split("\n") .join("\n" + (new Array(maxLen + 6).join(" ")))) }).join("\n") - return out } diff --git a/lib/install.js b/lib/install.js index b1c3809a4..c1f923e66 100644 --- a/lib/install.js +++ b/lib/install.js @@ -121,7 +121,7 @@ function install (args, cb_) { }) } - mkdir(where, function (er, made) { + mkdir(where, function (er) { if (er) return cb(er) // install dependencies locally by default, // or install current folder globally @@ -153,7 +153,6 @@ function install (args, cb_) { installManyTop(deps.map(function (dep) { var target = data.dependencies[dep] - , parsed = url.parse(target.replace(/^git\+/, "git")) target = dep + "@" + target return target }), where, context, function(er, results) { @@ -208,7 +207,7 @@ function findPeerInvalid_ (packageMap, fpiList) { if (pkg.peerInvalid) { var peersDepending = {}; - for (peerName in packageMap) { + for (var peerName in packageMap) { var peer = packageMap[peerName] if (peer.peerDependencies && peer.peerDependencies[packageName]) { peersDepending[peer.name + "@" + peer.version] = @@ -291,8 +290,9 @@ function readDependencies (context, where, opts, cb) { return cb(null, data, null) } + var newwrap try { - var newwrap = JSON.parse(wrapjson) + newwrap = JSON.parse(wrapjson) } catch (ex) { return cb(ex) } @@ -527,9 +527,6 @@ function installManyTop (what, where, context, cb_) { function installManyTop_ (what, where, context, cb) { var nm = path.resolve(where, "node_modules") - , names = context.explicit - ? what.map(function (w) { return w.split(/@/).shift() }) - : [] fs.readdir(nm, function (er, pkgs) { if (er) return installMany(what, where, context, cb) @@ -839,8 +836,6 @@ function installOne_ (target, where, context, cb) { if (prettyWhere === ".") prettyWhere = null if (isIncompatibleInstallOneInProgress(target, where)) { - var prettyTarget = path.relative(process.cwd(), targetFolder) - // just call back, with no error. the error will be detected in the // final check for peer-invalid dependencies return cb() @@ -980,7 +975,6 @@ function prepareForInstallMany (packageData, depsKey, bundled, wrap, family) { return true }).map(function (d) { var t = packageData[depsKey][d] - , parsed = url.parse(t.replace(/^git\+/, "git")) t = d + "@" + t return t }) diff --git a/lib/link.js b/lib/link.js index 562846550..8022fc78d 100644 --- a/lib/link.js +++ b/lib/link.js @@ -132,7 +132,7 @@ function linkPkg (folder, cb_) { if (er) return cb(er) log.verbose("link", "build target", target) // also install missing dependencies. - npm.commands.install(me, [], function (er, installed) { + npm.commands.install(me, [], function (er) { if (er) return cb(er) // build the global stuff. Don't run *any* scripts, because // install command already will have done that. @@ -74,11 +74,6 @@ function ls (args, silent, cb) { }) } -// only include -function filter (data, args) { - -} - function alphasort (a, b) { a = a.toLowerCase() b = b.toLowerCase() @@ -224,7 +219,6 @@ function makeArchy_ (data, long, dir, depth, parent, d) { if (typeof data === "string") { if (depth -1 <= npm.config.get("depth")) { // just missing - var p = parent.link || parent.path var unmet = "UNMET DEPENDENCY" if (color) { unmet = "\033[31;40m" + unmet + "\033[0m" @@ -267,8 +261,7 @@ function makeArchy_ (data, long, dir, depth, parent, d) { // add giturl to name@version if (data._resolved) { - var p = url.parse(data._resolved) - if (isGitUrl(p)) + if (isGitUrl(url.parse(data._resolved))) out.label += " (" + data._resolved + ")" } @@ -293,7 +286,7 @@ function makeArchy_ (data, long, dir, depth, parent, d) { return out } -function getExtras (data, dir) { +function getExtras (data) { var extras = [] if (data.description) extras.push(data.description) @@ -328,7 +321,6 @@ function makeParseable_ (data, long, dir, depth, parent, d) { if (typeof data === "string") { if (data.depth < npm.config.get("depth")) { - var p = parent.link || parent.path data = npm.config.get("long") ? path.resolve(parent.path, "node_modules", d) + ":"+d+"@"+JSON.stringify(data)+":INVALID:MISSING" diff --git a/lib/npm.js b/lib/npm.js index 344e4d348..7b9c54b07 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -15,8 +15,7 @@ if (typeof WScript !== "undefined") { require('child-process-close') var EventEmitter = require("events").EventEmitter - , npm = module.exports = new EventEmitter - , config = require("./config.js") + , npm = module.exports = new EventEmitter() , npmconf = require("npmconf") , log = require("npmlog") , fs = require("graceful-fs") diff --git a/lib/outdated.js b/lib/outdated.js index 9e78b64cc..b29ea9fe6 100644 --- a/lib/outdated.js +++ b/lib/outdated.js @@ -70,8 +70,7 @@ function outdated (args, silent, cb) { // [[ dir, dep, has, want, latest ]] function makePretty (p) { - var parseable = npm.config.get("parseable") - , dep = p[1] + var dep = p[1] , dir = path.resolve(p[0], "node_modules", dep) , has = p[2] , want = p[3] @@ -276,9 +275,6 @@ function shouldUpdate (args, dir, dep, has, req, depth, cb) { var l = d.versions[d['dist-tags'].latest] if (!l) return cb() - // set to true if found in doc - var found = false - var r = req if (d['dist-tags'][req]) r = d['dist-tags'][req] diff --git a/lib/prune.js b/lib/prune.js index eb58c7f64..edba87601 100644 --- a/lib/prune.js +++ b/lib/prune.js @@ -15,7 +15,7 @@ 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) { if (er) return cb(er) next() }) diff --git a/lib/publish.js b/lib/publish.js index b60760c57..ccad3ea82 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -3,10 +3,8 @@ module.exports = publish var npm = require("./npm.js") , log = require("npmlog") - , tar = require("./utils/tar.js") , path = require("path") , readJson = require("read-package-json") - , fs = require("graceful-fs") , lifecycle = require("./utils/lifecycle.js") , chain = require("slide").chain , Conf = require("npmconf").Conf diff --git a/lib/rebuild.js b/lib/rebuild.js index bd0d33b65..e296451b7 100644 --- a/lib/rebuild.js +++ b/lib/rebuild.js @@ -4,10 +4,7 @@ module.exports = rebuild var readInstalled = require("read-installed") , semver = require("semver") , log = require("npmlog") - , path = require("path") , npm = require("./npm.js") - , asyncMap = require("slide").asyncMap - , fs = require("graceful-fs") rebuild.usage = "npm rebuild [<name>[@<version>] [name[@<version>] ...]]" diff --git a/lib/repo.js b/lib/repo.js index 18b80615e..d209c3ca8 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -13,7 +13,6 @@ repo.completion = function (opts, cb) { var npm = require("./npm.js") , registry = npm.registry - , log = require("npmlog") , opener = require("opener") , github = require('github-url-from-git') , githubUserRepo = require("github-url-from-username-repo") diff --git a/lib/run-script.js b/lib/run-script.js index 8797ccd9d..25e98f01d 100644 --- a/lib/run-script.js +++ b/lib/run-script.js @@ -7,8 +7,6 @@ var lifecycle = require("./utils/lifecycle.js") , readJson = require("read-package-json") , log = require("npmlog") , chain = require("slide").chain - , fs = require("graceful-fs") - , asyncMap = require("slide").asyncMap runScript.usage = "npm run-script [<pkg>] <command>" diff --git a/lib/search.js b/lib/search.js index 72abbe8d6..06907dfe4 100644 --- a/lib/search.js +++ b/lib/search.js @@ -121,7 +121,7 @@ function filterWords (data, args, notArgs) { for (var i = 0, l = args.length; i < l; i ++) { if (!match(words, args[i])) return false } - for (var i = 0, l = notArgs.length; i < l; i ++) { + for (i = 0, l = notArgs.length; i < l; i ++) { if (match(words, notArgs[i])) return false } return true @@ -224,7 +224,7 @@ function addColorMarker (str, arg, i) { var pieces = str.toLowerCase().split(arg.toLowerCase()) , p = 0 - return pieces.map(function (piece, i) { + return pieces.map(function (piece) { piece = str.substr(p, piece.length) var mark = markStart + str.substr(p+piece.length, arg.length) @@ -245,12 +245,12 @@ function colorize (line) { } function getMaxWidth() { + var cols try { var tty = require("tty") , stdout = process.stdout - , cols = !tty.isatty(stdout.fd) ? Infinity - : process.stdout.getWindowSize()[0] - cols = (cols == 0) ? Infinity : cols + cols = !tty.isatty(stdout.fd) ? Infinity : process.stdout.getWindowSize()[0] + cols = (cols === 0) ? Infinity : cols } catch (ex) { cols = Infinity } return cols } diff --git a/lib/shrinkwrap.js b/lib/shrinkwrap.js index ef5732590..5f8261d09 100644 --- a/lib/shrinkwrap.js +++ b/lib/shrinkwrap.js @@ -60,8 +60,9 @@ function save (pkginfo, silent, cb) { // copy the keys over in a well defined order // because javascript objects serialize arbitrarily pkginfo.dependencies = sortedObject(pkginfo.dependencies || {}) + var swdata try { - var swdata = JSON.stringify(pkginfo, null, 2) + "\n" + swdata = JSON.stringify(pkginfo, null, 2) + "\n" } catch (er) { log.error("shrinkwrap", "Error converting package info to json") return cb(er) diff --git a/lib/submodule.js b/lib/submodule.js index 5ea5a4f46..544433af5 100644 --- a/lib/submodule.js +++ b/lib/submodule.js @@ -89,7 +89,7 @@ function addSubmodule (name, url, cb) { } -var getSubmodules = function getSubmodules (cb) { +var getSubmodules = function (cb) { var git = npm.config.get("git") var args = [ "submodule", "status" ] diff --git a/lib/test.js b/lib/test.js index d741807e6..dd4994cf2 100644 --- a/lib/test.js +++ b/lib/test.js @@ -1,7 +1,6 @@ module.exports = test var testCmd = require("./utils/lifecycle.js").cmd("test") - , log = require("npmlog") function test (args, cb) { testCmd(args, function (er) { diff --git a/lib/unbuild.js b/lib/unbuild.js index 433a6926e..b594f28a9 100644 --- a/lib/unbuild.js +++ b/lib/unbuild.js @@ -6,7 +6,6 @@ var readJson = require("read-package-json") , gentlyRm = require("./utils/gently-rm.js") , npm = require("./npm.js") , path = require("path") - , fs = require("graceful-fs") , lifecycle = require("./utils/lifecycle.js") , asyncMap = require("slide").asyncMap , chain = require("slide").chain @@ -87,12 +86,12 @@ function rmMans (pkg, folder, parent, top, cb) { var manRoot = path.resolve(npm.config.get("prefix"), "share", "man") asyncMap(pkg.man, function (man, cb) { if (Array.isArray(man)) { - man.forEach(rm) + man.forEach(rmMan) } else { - rm(man) + rmMan(man) } - function rm(man) { + function rmMan(man) { var parseMan = man.match(/(.*)\.([0-9]+)(\.gz)?$/) , stem = parseMan[1] , sxn = parseMan[2] diff --git a/lib/uninstall.js b/lib/uninstall.js index 072d46bcf..42a9a83e0 100644 --- a/lib/uninstall.js +++ b/lib/uninstall.js @@ -79,14 +79,15 @@ function saver (args, nm, cb_) { // don't use readJson here, because we don't want all the defaults // filled in, for mans and other bs. fs.readFile(pj, 'utf8', function (er, json) { + var pkg try { - var pkg = JSON.parse(json) + pkg = JSON.parse(json) } catch (_) {} if (!pkg) return cb_(null, data) var bundle if (npm.config.get('save-bundle')) { - var bundle = pkg.bundleDependencies || pkg.bundledDependencies + bundle = pkg.bundleDependencies || pkg.bundledDependencies if (!Array.isArray(bundle)) bundle = undefined } diff --git a/lib/unpublish.js b/lib/unpublish.js index d00bceaf5..64d022fe0 100644 --- a/lib/unpublish.js +++ b/lib/unpublish.js @@ -23,7 +23,6 @@ unpublish.completion = function (opts, cb) { if (!pkgs || !pkgs.length) return cb() var partial = opts.partialWord.split("@") , pp = partial.shift() - , pv = partial.join("@") pkgs = pkgs.filter(function (p) { return p.indexOf(pp) === 0 }) @@ -41,7 +40,6 @@ unpublish.completion = function (opts, cb) { } function unpublish (args, cb) { - if (args.length > 1) return cb(unpublish.usage) var thing = args.length ? args.shift().split("@") : [] diff --git a/lib/update.js b/lib/update.js index 9ae50dc41..06d199cc0 100644 --- a/lib/update.js +++ b/lib/update.js @@ -10,7 +10,6 @@ module.exports = update update.usage = "npm update [pkg]" var npm = require("./npm.js") - , lifecycle = require("./utils/lifecycle.js") , asyncMap = require("slide").asyncMap , log = require("npmlog") diff --git a/lib/version.js b/lib/version.js index ec3f93b20..a74f72ce1 100644 --- a/lib/version.js +++ b/lib/version.js @@ -89,7 +89,7 @@ function checkGit (data, cb) { }) function gitFound () { - exec(git, args, {env: env}, function (er, stdout, stderr) { + exec(git, args, {env: env}, function (er, stdout) { var lines = stdout.trim().split("\n").filter(function (line) { return line.trim() && !line.match(/^\?\? /) }).map(function (line) { diff --git a/lib/view.js b/lib/view.js index ae891e5ad..4931caef7 100644 --- a/lib/view.js +++ b/lib/view.js @@ -69,7 +69,7 @@ function view (args, silent, cb) { if (data.time && data.time.unpublished) { var u = data.time.unpublished - var er = new Error("Unpublished by " + u.name + " on " + u.time) + er = new Error("Unpublished by " + u.name + " on " + u.time) er.statusCode = 404 er.code = "E404" er.pkgid = data._id @@ -144,8 +144,9 @@ function search (data, fields, version, title) { , tail = fields while (!field && fields.length) field = tail.shift() fields = [field].concat(tail) + var o if (!field && !tail.length) { - var o = {} + o = {} o[version] = {} o[version][title] = data return o @@ -165,7 +166,6 @@ function search (data, fields, version, title) { return search(data[0], fields, version, title) } var results = [] - , res = null data.forEach(function (data, i) { var tl = title.length , newt = title.substr(0, tl-(fields.join(".").length) - 1) @@ -187,7 +187,7 @@ function search (data, fields, version, title) { return new Error("Not an object: "+data) } } - var o = {} + o = {} o[version] = {} o[version][title] = data return o @@ -199,7 +199,7 @@ function printData (data, name, cb) { , showVersions = versions.length > 1 , showFields - versions.forEach(function (v, i) { + versions.forEach(function (v) { var fields = Object.keys(data[v]) showFields = showFields || (fields.length > 1) fields.forEach(function (f) { diff --git a/lib/whoami.js b/lib/whoami.js index 664cbdbb0..f1c67e2b0 100644 --- a/lib/whoami.js +++ b/lib/whoami.js @@ -7,7 +7,7 @@ whoami.usage = "npm whoami\n(just prints the 'username' config)" function whoami (args, silent, cb) { if (typeof cb !== "function") cb = silent, silent = false var me = npm.config.get("username") - msg = me ? me : "Not authed. Run 'npm adduser'" + var msg = me ? me : "Not authed. Run 'npm adduser'" if (!silent) console.log(msg) process.nextTick(cb.bind(this, null, me)) } diff --git a/lib/xmas.js b/lib/xmas.js index bf838a87a..fa8d1db55 100644 --- a/lib/xmas.js +++ b/lib/xmas.js @@ -1,6 +1,5 @@ // happy xmas -var npm = require("./npm.js") - , log = require("npmlog") +var log = require("npmlog") module.exports = function (args, cb) { var s = process.platform === "win32" ? " *" : " \u2605" @@ -20,26 +19,26 @@ w("\n") for (var i = 0; i < H; i ++) w(" ") w(x+"\033[33m"+s+"\n") var M = H * 2 - 1 - for (L = 1; L <= H; L ++) { + for (var L = 1; L <= H; L ++) { var O = L * 2 - 2 var S = (M - O) / 2 - for (var i = 0; i < S; i ++) w(" ") + for (i = 0; i < S; i ++) w(" ") w(x+"\033[32m"+f) - for (var i = 0; i < O; i ++) w( + for (i = 0; i < O; i ++) w( "\033["+oc[Math.floor(Math.random()*oc.length)]+"m"+ o[Math.floor(Math.random() * o.length)] ) w(x+"\033[32m"+b+"\n") } w(" ") - for (var i = 1; i < H; i ++) w("\033[32m"+l) + for (i = 1; i < H; i ++) w("\033[32m"+l) w("| "+x+" |") - for (var i = 1; i < H; i ++) w("\033[32m"+l) + for (i = 1; i < H; i ++) w("\033[32m"+l) if (H > 10) { w("\n ") - for (var i = 1; i < H; i ++) w(" ") + for (i = 1; i < H; i ++) w(" ") w("| "+x+" |") - for (var i = 1; i < H; i ++) w(" ") + for (i = 1; i < H; i ++) w(" ") } })(20) w("\n\n") |