Skip to content

Commit

Permalink
src: Update formatting to be compatible with standard@5
Browse files Browse the repository at this point in the history
PR-URL: npm/npm#9954
  • Loading branch information
sebdeckers authored and iarna committed Oct 21, 2015
1 parent 8946cb3 commit 40c1b0f
Show file tree
Hide file tree
Showing 68 changed files with 1,014 additions and 993 deletions.
1 change: 0 additions & 1 deletion bin/npm-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,4 @@
if (er) return errorHandler(er)
npm.commands[npm.command](npm.argv, errorHandler)
})

})()
2 changes: 0 additions & 2 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,10 @@ function shouldWarn (pkg, folder, global, cb) {

// current searched package is the linked package on first call
if (linkedPkg !== currentPkg) {

// don't generate a warning if it's listed in dependencies
if (Object.keys(topPkg.dependencies || {})
.concat(Object.keys(topPkg.devDependencies || {}))
.indexOf(currentPkg) === -1) {

if (top && pkg.preferGlobal && !global) {
log.warn('prefer global', packageId(pkg) + ' should be installed with -g')
}
Expand Down
1 change: 0 additions & 1 deletion lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ cache.usage = 'npm cache add <tarball file>' +
'\nnpm cache clean [<pkg>[@<version>]]'

cache.completion = function (opts, cb) {

var argv = opts.conf.argv.remain
if (argv.length === 2) {
return cb(null, ['add', 'ls', 'clean'])
Expand Down
2 changes: 0 additions & 2 deletions lib/cache/add-local-tarball.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ function addTmpTarball_ (tgz, data, shasum, cb) {
getCacheStat(function (er, cs) {
if (er) return cb(er)
mkdir(pkg, function (er, created) {

// chown starting from the first dir created by mkdirp,
// or the root dir, if none had to be created, so that
// we know that we get all the children.
Expand All @@ -167,7 +166,6 @@ function addTmpTarball_ (tgz, data, shasum, cb) {
var fin = cs.uid && cs.gid ? chown : done
read.on('error', cb).pipe(write).on('error', cb).on('close', fin)
})

})

function done () {
Expand Down
2 changes: 1 addition & 1 deletion lib/cache/caching-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ inherits(CachingRegistryClient, RegistryClient)

CachingRegistryClient.prototype._invalidatingRequest = function (uri, params, cb) {
var client = this
this._request.call(this, uri, params, function () {
this._request(uri, params, function () {
var args = arguments

var method = params.method
Expand Down
6 changes: 2 additions & 4 deletions lib/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ var configDefs = npmconf.defs
var configTypes = configDefs.types
var shorthands = configDefs.shorthands
var nopt = require('nopt')
var configNames = Object.keys(configTypes).filter(function (e) {
return e.charAt(0) !== '_'
})
var configNames = Object.keys(configTypes)
.filter(function (e) { return e.charAt(0) !== '_' })
var shorthandNames = Object.keys(shorthands)
var allConfs = configNames.concat(shorthandNames)
var once = require('once')
Expand Down Expand Up @@ -167,7 +166,6 @@ function dumpScript (cb) {
if (er.errno === 'EPIPE') er = null
cb(er)
})

})
}

Expand Down
28 changes: 14 additions & 14 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ function edit (cb) {
if (er) data = ''
data = [
';;;;',
'; npm ' + (npm.config.get('global') ?
'globalconfig' : 'userconfig') + ' file',
'; npm ' + (npm.config.get('global')
? 'globalconfig' : 'userconfig') + ' file',
'; this is a simple ini-formatted file',
'; lines that start with semi-colons are comments.',
'; read `npm help config` for help on the various options',
Expand All @@ -86,18 +86,18 @@ function edit (cb) {
'; all options with default values',
';;;;'
]).concat(Object.keys(npmconf.defaults).reduce(function (arr, key) {
var obj = {}
obj[key] = npmconf.defaults[key]
if (key === 'logstream') return arr
return arr.concat(
ini.stringify(obj)
.replace(/\n$/m, '')
.replace(/^/g, '; ')
.replace(/\n/g, '\n; ')
.split('\n'))
}, []))
.concat([''])
.join(os.EOL)
var obj = {}
obj[key] = npmconf.defaults[key]
if (key === 'logstream') return arr
return arr.concat(
ini.stringify(obj)
.replace(/\n$/m, '')
.replace(/^/g, '; ')
.replace(/\n/g, '\n; ')
.split('\n'))
}, []))
.concat([''])
.join(os.EOL)
writeFileAtomic(
f,
data,
Expand Down
1 change: 0 additions & 1 deletion lib/config/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ Conf.prototype.save = function (where, cb) {
fs.writeFile(target.path, data, 'utf8', function (er) {
if (er) return then(er)
if (where === 'user' && myUid && myGid) {

fs.chown(target.path, +myUid, +myGid, then)
} else {
then()
Expand Down
1 change: 0 additions & 1 deletion lib/config/load-cafile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function loadCAFile (cafilePath, cb) {
fs.readFile(cafilePath, 'utf8', afterCARead.bind(this))

function afterCARead (er, cadata) {

if (er) {
// previous cafile no longer exists, so just continue on gracefully
if (er.code === 'ENOENT') return cb()
Expand Down
6 changes: 4 additions & 2 deletions lib/config/load-prefix.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ function loadPrefix (cb) {
var cli = this.list[0]

Object.defineProperty(this, 'prefix',
{ set: function (prefix) {
{
set: function (prefix) {
var g = this.get('global')
this[g ? 'globalPrefix' : 'localPrefix'] = prefix
}.bind(this),
Expand All @@ -19,7 +20,8 @@ function loadPrefix (cb) {
})

Object.defineProperty(this, 'globalPrefix',
{ set: function (prefix) {
{
set: function (prefix) {
this.set('prefix', prefix)
}.bind(this),
get: function () {
Expand Down
8 changes: 4 additions & 4 deletions lib/dedupe.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ Deduper.prototype.loadIdealTree = function (cb) {
[this, this.finishTracker, 'cloneCurrentTree'],

[this.newTracker(this.progress.loadIdealTree, 'loadAllDepsIntoIdealTree', 10)],
[function (next) {
[ function (next) {
loadExtraneous(self.idealTree, self.progress.loadAllDepsIntoIdealTree, next)
}],
} ],
[this, this.finishTracker, 'loadAllDepsIntoIdealTree'],

[this, function (next) { recalculateMetadata(this.idealTree, log, next) }]
Expand Down Expand Up @@ -151,10 +151,10 @@ function hoistChildren_ (tree, diff, seen, next) {
chain([
[recalculateMetadata, hoistTo, log],
[hoistChildren_, child, diff, seen],
[function (next) {
[ function (next) {
moveRemainingChildren(child, diff)
next()
}]
} ]
], done)
} else {
done()
Expand Down
41 changes: 21 additions & 20 deletions lib/help-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,12 @@ function formatResults (args, results, cb) {

var out = results.map(function (res) {
var out = res.cmd
var r = Object.keys(res.hits).map(function (k) {
return k + ':' + res.hits[k]
}).sort(function (a, b) {
return a > b ? 1 : -1
}).join(' ')
var r = Object.keys(res.hits)
.map(function (k) {
return k + ':' + res.hits[k]
}).sort(function (a, b) {
return a > b ? 1 : -1
}).join(' ')

out += ((new Array(Math.max(1, cols - out.length - r.length)))
.join(' ')) + r
Expand All @@ -175,25 +176,25 @@ function formatResults (args, results, cb) {
out = '\n\n' + out + '\n' +
(new Array(cols)).join('—') + '\n' +
res.lines.map(function (line, i) {
if (line === null || i > 3) return ''
for (var out = line, a = 0, l = args.length; a < l; a++) {
var finder = out.toLowerCase().split(args[a].toLowerCase())
var newOut = ''
var p = 0
if (line === null || i > 3) return ''
for (var out = line, a = 0, l = args.length; a < l; a++) {
var finder = out.toLowerCase().split(args[a].toLowerCase())
var newOut = ''
var p = 0

finder.forEach(function (f) {
newOut += out.substr(p, f.length)
finder.forEach(function (f) {
newOut += out.substr(p, f.length)

var hilit = out.substr(p + f.length, args[a].length)
if (npm.color) hilit = color.bgBlack(color.red(hilit))
newOut += hilit
var hilit = out.substr(p + f.length, args[a].length)
if (npm.color) hilit = color.bgBlack(color.red(hilit))
newOut += hilit

p += f.length + args[a].length
})
}
p += f.length + args[a].length
})
}

return newOut
}).join('\n').trim()
return newOut
}).join('\n').trim()
return out
}).join('\n')

Expand Down
4 changes: 2 additions & 2 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ Installer.prototype.loadIdealTree = function (cb) {
[this, this.loadAllDepsIntoIdealTree],
[this, this.finishTracker, 'loadAllDepsIntoIdealTree'],

[this, function (next) { recalculateMetadata(this.idealTree, log, next) } ],
[this, function (next) { recalculateMetadata(this.idealTree, log, next) }],
[this, this.debugTree, 'idealTree:prePrune', 'idealTree'],
[this, function (next) { next(pruneTree(this.idealTree)) } ]
[this, function (next) { next(pruneTree(this.idealTree)) }]
], cb)
}

Expand Down
9 changes: 5 additions & 4 deletions lib/install/action/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ module.exports = function (top, buildpath, pkg, log, next) {
var group = up ? null : npm.config.get('group')
cache.unpack(pkg.package.name, pkg.package.version
, buildpath
, null, null, user, group, function (er) {
if (er) return next(er)
updatePackageJson(pkg, buildpath, next)
})
, null, null, user, group,
function (er) {
if (er) return next(er)
updatePackageJson(pkg, buildpath, next)
})
}
6 changes: 3 additions & 3 deletions lib/install/mutate-into-logical-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ var mutateIntoLogicalTree = module.exports = function (tree) {
var flat = flattenTree(tree)

function getNode (flatname) {
return flatname.substr(0, 5) === '#DEV:' ?
flat[flatname.substr(5)] :
flat[flatname]
return flatname.substr(0, 5) === '#DEV:'
? flat[flatname.substr(5)]
: flat[flatname]
}

Object.keys(flat).sort().forEach(function (flatname) {
Expand Down
6 changes: 3 additions & 3 deletions lib/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ function linkInstall (pkgs, cb) {
if (npm.config.get('dry-run')) return resultPrinter(pkg, pp, target, rp, cb)
chain(
[
[function (cb) {
[ function (cb) {
log.verbose('link', 'symlinking %s to %s', pp, target)
cb()
}],
} ],
[symlink, pp, target],
// do not run any scripts
rp && [build, [target], npm.config.get('global'), build._noLC, true],
[resultPrinter, pkg, pp, target, rp ]
[resultPrinter, pkg, pp, target, rp]
],
cb
)
Expand Down
22 changes: 14 additions & 8 deletions lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@
]
var littleGuys = [ 'isntall' ]
var fullList = cmdList.concat(aliasNames).filter(function (c) {
return plumbing.indexOf(c) === -1
})
return plumbing.indexOf(c) === -1
})
var abbrevs = abbrev(fullList)

// we have our reasons
Expand Down Expand Up @@ -387,7 +387,8 @@
}

Object.defineProperty(npm, 'prefix',
{ get: function () {
{
get: function () {
return npm.config.get('global') ? npm.globalPrefix : npm.localPrefix
},
set: function (r) {
Expand All @@ -399,31 +400,35 @@
})

Object.defineProperty(npm, 'bin',
{ get: function () {
{
get: function () {
if (npm.config.get('global')) return npm.globalBin
return path.resolve(npm.root, '.bin')
},
enumerable: true
})

Object.defineProperty(npm, 'globalBin',
{ get: function () {
{
get: function () {
var b = npm.globalPrefix
if (process.platform !== 'win32') b = path.resolve(b, 'bin')
return b
}
})

Object.defineProperty(npm, 'dir',
{ get: function () {
{
get: function () {
if (npm.config.get('global')) return npm.globalDir
return path.resolve(npm.prefix, 'node_modules')
},
enumerable: true
})

Object.defineProperty(npm, 'globalDir',
{ get: function () {
{
get: function () {
return (process.platform !== 'win32')
? path.resolve(npm.globalPrefix, 'lib', 'node_modules')
: path.resolve(npm.globalPrefix, 'node_modules')
Expand All @@ -443,7 +448,8 @@
var tmpFolder
var rand = require('crypto').randomBytes(4).toString('hex')
Object.defineProperty(npm, 'tmp',
{ get: function () {
{
get: function () {
if (!tmpFolder) tmpFolder = 'npm-' + process.pid + '-' + rand
return path.resolve(npm.config.get('tmp'), tmpFolder)
},
Expand Down
4 changes: 2 additions & 2 deletions lib/outdated.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ function shouldUpdate (args, tree, dep, has, req, depth, pkgpath, cb, type) {

function doIt (wanted, latest) {
if (!long) {
return cb(null, [[ tree, dep, curr && curr.version, wanted, latest, req, null, pkgpath]])
return cb(null, [[tree, dep, curr && curr.version, wanted, latest, req, null, pkgpath]])
}
cb(null, [[ tree, dep, curr && curr.version, wanted, latest, req, type, pkgpath]])
cb(null, [[tree, dep, curr && curr.version, wanted, latest, req, type, pkgpath]])
}

if (args.length && args.indexOf(dep) === -1) return skip()
Expand Down
2 changes: 1 addition & 1 deletion lib/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ function unknownHostedUrl (url) {
: 'http:'
return protocol + '//' + (url.host || '') +
url.path.replace(/\.git$/, '')
} catch(e) {}
} catch (e) {}
}
1 change: 0 additions & 1 deletion lib/run-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ runScript.usage = 'npm run-script <command> [-- <args>...]' +
'\n\nalias: npm run'

runScript.completion = function (opts, cb) {

// see if there's already a package specified.
var argv = opts.conf.argv.remain

Expand Down
Loading

0 comments on commit 40c1b0f

Please sign in to comment.