Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/install')
-rw-r--r--lib/install/action/move.js7
-rw-r--r--lib/install/actions.js9
-rw-r--r--lib/install/decompose-actions.js9
-rw-r--r--lib/install/deps.js37
-rw-r--r--lib/install/diff-trees.js10
-rw-r--r--lib/install/filter-invalid-actions.js6
-rw-r--r--lib/install/inflate-bundled.js2
-rw-r--r--lib/install/inflate-shrinkwrap.js4
-rw-r--r--lib/install/logical-tree.js5
-rw-r--r--lib/install/prune-tree.js2
-rw-r--r--lib/install/save.js8
11 files changed, 41 insertions, 58 deletions
diff --git a/lib/install/action/move.js b/lib/install/action/move.js
index 841fbc155..57aa5f7fb 100644
--- a/lib/install/action/move.js
+++ b/lib/install/action/move.js
@@ -5,7 +5,6 @@ var chain = require('slide').chain
var iferr = require('iferr')
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
-var npm = require('../../npm.js')
var rmStuff = require('../../unbuild.js').rmStuff
var lifecycle = require('../../utils/lifecycle.js')
var updatePackageJson = require('../update-package-json')
@@ -33,12 +32,12 @@ function noerrors () {
if (er) {
log.warn('move', er)
}
- cb.apply(null, a)
+ cb.apply(null, args)
})
}
module.exports.rollback = function (buildpath, pkg, next) {
- chian([
+ chain([
[noerrors, mkdirp, path.resolve(pkg.fromPath, '..')],
[noerrors, lifecycle, pkg.package, 'preuninstall', pkg.path, false, true],
[noerrors, lifecycle, pkg.package, 'uninstall', pkg.path, false, true],
@@ -47,7 +46,7 @@ module.exports.rollback = function (buildpath, pkg, next) {
[noerrors, moveModuleOnly, pkg.path, pkg.fromPath],
[noerrors, lifecycle, pkg.package, 'preinstall', pkg.fromPath, false, true],
[noerrors, removeEmptyParents, path.resolve(pkg.path, '..')],
- [noerrors, updatePackageJson, pkg, pkg.fromPath],
+ [noerrors, updatePackageJson, pkg, pkg.fromPath]
], next)
}
diff --git a/lib/install/actions.js b/lib/install/actions.js
index f425efd65..a19cb1cb1 100644
--- a/lib/install/actions.js
+++ b/lib/install/actions.js
@@ -26,7 +26,6 @@ actions['update-linked'] = require('./action/update-linked.js')
actions['global-install'] = require('./action/global-install.js')
actions['global-link'] = require('./action/global-link.js')
-
// FIXME: We wrap actions like three ways to sunday here.
// Rewrite this to only work one way.
@@ -44,19 +43,19 @@ Object.keys(actions).forEach(function (actionName) {
}
})
-function andHandleOptionalDepErrors(pkg, next) {
+function andHandleOptionalDepErrors (pkg, next) {
return function (er) {
if (!er) return next.apply(null, arguments)
pkg.failed = true
var anyFatal = pkg.directlyRequested || !pkg.parent
- for (var ii=0; ii < pkg.requiredBy.length; ++ii) {
+ for (var ii = 0; ii < pkg.requiredBy.length; ++ii) {
var parent = pkg.requiredBy[ii]
var isFatal = failedDependency(parent, pkg)
if (isFatal) anyFatal = true
}
if (anyFatal) return next.apply(null, arguments)
- log.warn('install:'+pkg.package.name, "Couldn't install optional dependency:", er.message)
- log.verbose('install:'+pkg.package.name, er.stack)
+ log.warn('install:' + pkg.package.name, "Couldn't install optional dependency:", er.message)
+ log.verbose('install:' + pkg.package.name, er.stack)
next()
}
}
diff --git a/lib/install/decompose-actions.js b/lib/install/decompose-actions.js
index 2921fccba..b345ba5d0 100644
--- a/lib/install/decompose-actions.js
+++ b/lib/install/decompose-actions.js
@@ -1,9 +1,6 @@
'use strict'
-var fs = require('fs')
-var path = require('path')
var validate = require('aproba')
var asyncMap = require('slide').asyncMap
-var npm = require('../npm.js')
module.exports = function (differences, decomposed, next) {
validate('AAF', arguments)
@@ -26,7 +23,7 @@ module.exports = function (differences, decomposed, next) {
}, next)
}
-function addSteps(decomposed, pkg, done) {
+function addSteps (decomposed, pkg, done) {
decomposed.push(['fetch', pkg])
decomposed.push(['extract', pkg])
decomposed.push(['preinstall', pkg])
@@ -38,7 +35,7 @@ function addSteps(decomposed, pkg, done) {
done()
}
-function moveSteps(decomposed, pkg, done) {
+function moveSteps (decomposed, pkg, done) {
decomposed.push(['move', pkg])
decomposed.push(['build', pkg])
decomposed.push(['install', pkg])
@@ -47,7 +44,7 @@ function moveSteps(decomposed, pkg, done) {
done()
}
-function defaultSteps(decomposed, cmd, pkg, done) {
+function defaultSteps (decomposed, cmd, pkg, done) {
decomposed.push([cmd, pkg])
done()
}
diff --git a/lib/install/deps.js b/lib/install/deps.js
index 98c094846..20b7eb30f 100644
--- a/lib/install/deps.js
+++ b/lib/install/deps.js
@@ -1,7 +1,7 @@
'use strict'
var assert = require('assert')
-var fs = require('graceful-fs')
var path = require('path')
+var url = require('url')
var semver = require('semver')
var asyncMap = require('slide').asyncMap
var chain = require('slide').chain
@@ -42,23 +42,23 @@ function isDevDep (tree, name) {
var devDeps = tree.package.devDependencies || {}
var reqVer = devDeps[name]
if (reqVer == null) return
- return npa(name + "@" + reqVer)
+ return npa(name + '@' + reqVer)
}
function isProdDep (tree, name) {
var deps = tree.package.dependencies || {}
var reqVer = deps[name]
if (reqVer == null) return false
- return npa(name + "@" + reqVer)
+ return npa(name + '@' + reqVer)
}
var registryTypes = { range: true, version: true }
-function doesChildVersionMatch(child, requested) {
+function doesChildVersionMatch (child, requested) {
if (child.fromShrinkwrap) return true
var childReq = child.package._requested
if (childReq) {
- if (childReq.rawSpec == requested.rawSpec) return true
+ if (childReq.rawSpec === requested.rawSpec) return true
if (childReq.type === requested.type && childReq.spec === requested.spec) return true
}
if (!registryTypes[requested.type]) return requested.rawSpec === child.package._from
@@ -86,11 +86,6 @@ var recalculateMetadata = exports.recalculateMetadata = function (tree, log, nex
}
})
}
- function deptospec (deps) {
- return function (depname) {
- return depname + '@' + deps[depname]
- }
- }
function specs (deps) {
return Object.keys(deps).map(function (depname) { return depname + '@' + deps[depname] })
}
@@ -105,19 +100,15 @@ var recalculateMetadata = exports.recalculateMetadata = function (tree, log, nex
], function () { next(null, tree) })
}
-function addRequiredDep(tree, child) {
+function addRequiredDep (tree, child) {
if (!isDep(tree, child)) return false
- var name = isProdDep(tree, child.package.name) ? flatNameFromTree(tree) : "#DEV:"+flatNameFromTree(tree)
+ var name = isProdDep(tree, child.package.name) ? flatNameFromTree(tree) : '#DEV:' + flatNameFromTree(tree)
child.package._requiredBy = union(child.package._requiredBy || [], [name])
child.requiredBy = union(child.requiredBy || [], [tree])
return true
}
-function matchingChild(tree, name) {
- var matches = tree.children.filter(function (child) { return child.package.name === name })
- return matches[0]
-}
-function matchingDep(tree, name) {
+function matchingDep (tree, name) {
if (tree.package.dependencies[name]) return tree.package.dependencies[name]
if (tree.package.devDependencies && tree.package.devDependencies[name]) return tree.package.devDependencies[name]
return
@@ -129,7 +120,7 @@ function packageRelativePath (tree) {
return isLocal ? requested.spec : tree.path
}
-function getShrinkwrap(tree, name) {
+function getShrinkwrap (tree, name) {
return tree.package._shrinkwrap && tree.package._shrinkwrap.dependencies && tree.package._shrinkwrap.dependencies[name]
}
@@ -176,7 +167,7 @@ exports.loadRequestedDeps = function (args, tree, saveToDependencies, log, next)
// For things the user asked to install, that aren't a dependency (or
// won't be when we're done), flag it as "depending" on the user
// themselves, so we don't remove it as a dep that no longer exists
- if (! addRequiredDep(tree, child)) {
+ if (!addRequiredDep(tree, child)) {
child.package._requiredBy = union(child.package._requiredBy, ['#USER'])
child.directlyRequested = true
}
@@ -250,7 +241,7 @@ var failedDependency = exports.failedDependency = function (tree, name_pkg) {
if (!tree.parent) return true
- for (var ii=0; ii<tree.requiredBy.length; ++ii) {
+ for (var ii = 0; ii < tree.requiredBy.length; ++ii) {
var requireParent = tree.requiredBy[ii]
if (failedDependency(requireParent, tree.package)) {
return true
@@ -265,7 +256,7 @@ function andHandleOptionalErrors (log, tree, name, done) {
validate('EOO', [er, child, childLog])
if (!er) return done(er, child, childLog)
var isFatal = failedDependency(tree, name)
- if (er && ! isFatal) {
+ if (er && !isFatal) {
tree.children = tree.children.filter(function (child) { return child.package.name !== name })
log.warn('install', "Couldn't install optional dependency:", er.message)
log.verbose('install', er.stack)
@@ -420,7 +411,7 @@ var validatePeerDeps = exports.validatePeerDeps = function (tree, onInvalid) {
if (!tree.package.peerDependencies) return
Object.keys(tree.package.peerDependencies).forEach(function (pkgname) {
var version = tree.package.peerDependencies[pkgname]
- var match = findRequirement(tree, pkgname, npa(pkgname + "@" + version))
+ var match = findRequirement(tree, pkgname, npa(pkgname + '@' + version))
if (!match) onInvalid(tree, pkgname, version)
})
}
@@ -439,7 +430,7 @@ var findRequirement = exports.findRequirement = function (tree, name, requested)
return child.package.name === name && child.parent
}
var versionMatch = function (child) {
- return doesChildVersionMatch(child, requested)
+ return doesChildVersionMatch(child, requested)
}
if (nameMatch(tree)) {
// this *is* the module, but it doesn't match the version, so a
diff --git a/lib/install/diff-trees.js b/lib/install/diff-trees.js
index 3363e33c5..e52d950bf 100644
--- a/lib/install/diff-trees.js
+++ b/lib/install/diff-trees.js
@@ -62,7 +62,6 @@ function requiredByAllLinked (node) {
var sortActions = module.exports.sortActions = function (differences) {
var actions = {}
differences.forEach(function (action) {
- var cmd = action[0]
var child = action[1]
actions[child.package._location] = action
})
@@ -107,16 +106,15 @@ function diffTrees (oldTree, newTree) {
Object.keys(flatNewTree).forEach(function (path) {
var pkg = flatNewTree[path]
pkg.oldPkg = flatOldTree[path]
- pkg.isInLink = (pkg.oldPkg && isLink(pkg.oldPkg.parent))
- || (pkg.parent && isLink(pkg.parent))
- || requiredByAllLinked(pkg)
+ pkg.isInLink = (pkg.oldPkg && isLink(pkg.oldPkg.parent)) ||
+ (pkg.parent && isLink(pkg.parent)) ||
+ requiredByAllLinked(pkg)
if (pkg.fromBundle) return
if (pkg.oldPkg) {
if (!pkg.directlyRequested && pkgAreEquiv(pkg.oldPkg.package, pkg.package)) return
if (!pkg.isInLink && (isLink(pkg.oldPkg) || isLink(pkg))) {
differences.push(['update-linked', pkg])
- }
- else {
+ } else {
differences.push(['update', pkg])
}
} else {
diff --git a/lib/install/filter-invalid-actions.js b/lib/install/filter-invalid-actions.js
index 311a60863..e844e0a3f 100644
--- a/lib/install/filter-invalid-actions.js
+++ b/lib/install/filter-invalid-actions.js
@@ -7,17 +7,17 @@ module.exports = function (top, differences, next) {
validate('SAF', arguments)
var action
var keep = []
+ /*eslint no-cond-assign:0*/
while (action = differences.shift()) {
var cmd = action[0]
var pkg = action[1]
if (pkg.isInLink || pkg.parent.target) {
log.warn('skippingAction', 'Module is inside a symlinked module: not running ' +
cmd + ' ' + pkg.package._id + ' ' + path.relative(top, pkg.path))
- }
- else {
+ } else {
keep.push(action)
}
}
differences.push.apply(differences, keep)
next()
-} \ No newline at end of file
+}
diff --git a/lib/install/inflate-bundled.js b/lib/install/inflate-bundled.js
index 913a05846..c27acd1dc 100644
--- a/lib/install/inflate-bundled.js
+++ b/lib/install/inflate-bundled.js
@@ -12,4 +12,4 @@ module.exports = function inflateBundled (parent, children) {
child.isLink = child.isLink || parent.isLink || parent.target
inflateBundled(child, child.children)
})
-} \ No newline at end of file
+}
diff --git a/lib/install/inflate-shrinkwrap.js b/lib/install/inflate-shrinkwrap.js
index 128d44f57..dd32583f6 100644
--- a/lib/install/inflate-shrinkwrap.js
+++ b/lib/install/inflate-shrinkwrap.js
@@ -27,8 +27,8 @@ var inflateShrinkwrap = module.exports = function (tree, swdeps, finishInflating
var child = onDisk[name]
if (child && (child.fromShrinkwrap ||
(sw.resolved && child.package._resolved === sw.resolved) ||
- (sw.from && url.parse(sw.from).protocol && child.package._from == sw.from) ||
- child.package.version == sw.version)) {
+ (sw.from && url.parse(sw.from).protocol && child.package._from === sw.from) ||
+ child.package.version === sw.version)) {
if (!child.fromShrinkwrap) child.fromShrinkwrap = spec
tree.children.push(child)
return next()
diff --git a/lib/install/logical-tree.js b/lib/install/logical-tree.js
index f0faf6e78..1d9492bdf 100644
--- a/lib/install/logical-tree.js
+++ b/lib/install/logical-tree.js
@@ -4,7 +4,6 @@ var union = require('lodash.union')
var without = require('lodash.without')
var validate = require('aproba')
var flattenTree = require('./flatten-tree.js')
-var npm = require('../npm.js')
var isExtraneous = require('./is-extraneous.js')
var validateAllPeerDeps = require('./deps.js').validateAllPeerDeps
@@ -21,7 +20,7 @@ var logicalTree = module.exports = function (tree) {
var flat = flattenTree(newTree)
function getNode (flatname) {
- return flatname.substr(0,5) === '#DEV:' ?
+ return flatname.substr(0, 5) === '#DEV:' ?
flat[flatname.substr(5)] :
flat[flatname]
}
@@ -35,7 +34,7 @@ var logicalTree = module.exports = function (tree) {
return parentNode.package.dependencies[node.package.name] ||
(parentNode.package.devDependencies && parentNode.package.devDependencies[node.package.name])
})
- var requiredBy = requiredByNames.map(getNode)
+ requiredBy = requiredByNames.map(getNode)
node.requiredBy = requiredBy
diff --git a/lib/install/prune-tree.js b/lib/install/prune-tree.js
index 3a8e41d9f..eb3edf4f7 100644
--- a/lib/install/prune-tree.js
+++ b/lib/install/prune-tree.js
@@ -19,7 +19,7 @@ module.exports = function pruneTree (tree) {
var child = flat[flatname]
if (!child.parent) return
child.package._requiredBy = (child.package._requiredBy || []).filter(function (req) {
- var isDev = req.substr(0,4) === '#DEV'
+ var isDev = req.substr(0, 4) === '#DEV'
if (req[0] === '#' && !isDev) return true
if (flat[req]) return true
if (!isDev) return false
diff --git a/lib/install/save.js b/lib/install/save.js
index 350480d66..9f649ccca 100644
--- a/lib/install/save.js
+++ b/lib/install/save.js
@@ -113,9 +113,9 @@ var getSaveType = exports.getSaveType = function (args) {
validate('A', arguments)
var nothingToSave = !args.length
var globalInstall = npm.config.get('global')
- var noSaveFlags = !npm.config.get('save')
- && !npm.config.get('save-dev')
- && !npm.config.get('save-optional')
+ var noSaveFlags = !npm.config.get('save') &&
+ !npm.config.get('save-dev') &&
+ !npm.config.get('save-optional')
if (nothingToSave || globalInstall || noSaveFlags) return null
if (npm.config.get('save-optional')) return 'optionalDependencies'
@@ -127,7 +127,7 @@ function computeVersionSpec (child) {
validate('O', arguments)
var requested = child.package._requested
if (!requested || requested.type === 'tag') {
- requested = {
+ requested = {
type: 'version',
spec: child.package.version
}