summaryrefslogtreecommitdiff
path: root/deps/npm/lib/install.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/install.js')
-rw-r--r--deps/npm/lib/install.js37
1 files changed, 15 insertions, 22 deletions
diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js
index 53153e1463..1fb5a4f4e6 100644
--- a/deps/npm/lib/install.js
+++ b/deps/npm/lib/install.js
@@ -113,6 +113,7 @@ var lock = locker.lock
var unlock = locker.unlock
var ls = require('./ls.js')
var parseJSON = require('./utils/parse-json.js')
+var output = require('./utils/output.js')
// install specific libraries
var copyTree = require('./install/copy-tree.js')
@@ -123,7 +124,6 @@ var loadDevDeps = require('./install/deps.js').loadDevDeps
var getAllMetadata = require('./install/deps.js').getAllMetadata
var loadRequestedDeps = require('./install/deps.js').loadRequestedDeps
var loadExtraneous = require('./install/deps.js').loadExtraneous
-var pruneTree = require('./install/prune-tree.js')
var diffTrees = require('./install/diff-trees.js')
var checkPermissions = require('./install/check-permissions.js')
var decomposeActions = require('./install/decompose-actions.js')
@@ -136,9 +136,11 @@ var doSerialActions = require('./install/actions.js').doSerial
var doReverseSerialActions = require('./install/actions.js').doReverseSerial
var doParallelActions = require('./install/actions.js').doParallel
var doOneAction = require('./install/actions.js').doOne
+var removeObsoleteDep = require('./install/deps.js').removeObsoleteDep
var packageId = require('./utils/package-id.js')
var moduleName = require('./utils/module-name.js')
var errorMessage = require('./utils/error-message.js')
+var andIgnoreErrors = require('./install/and-ignore-errors.js')
function unlockCB (lockPath, name, cb) {
validate('SSF', arguments)
@@ -363,9 +365,8 @@ Installer.prototype.loadIdealTree = function (cb) {
[this, this.loadAllDepsIntoIdealTree],
[this, this.finishTracker, 'loadAllDepsIntoIdealTree'],
- [this, function (next) { recalculateMetadata(this.idealTree, log, next) }],
- [this, this.debugTree, 'idealTree:prePrune', 'idealTree'],
- [this, function (next) { next(pruneTree(this.idealTree)) }]
+ // TODO: Remove this (should no longer be necessary, instead counter productive)
+ [this, function (next) { recalculateMetadata(this.idealTree, log, next) }]
], cb)
}
@@ -419,21 +420,18 @@ Installer.prototype.computeLinked = function (cb) {
var cmd = action[0]
var pkg = action[1]
if (cmd !== 'add' && cmd !== 'update') return next()
- var isReqByTop = pkg.package._requiredBy.filter(function (name) { return name === '/' }).length
- var isReqByUser = pkg.package._requiredBy.filter(function (name) { return name === '#USER' }).length
- var isExtraneous = pkg.package._requiredBy.length === 0
+ var isReqByTop = pkg.requiredBy.filter(function (mod) { return mod.isTop }).length
+ var isReqByUser = pkg.userRequired
+ var isExtraneous = pkg.requiredBy.length === 0
if (!isReqByTop && !isReqByUser && !isExtraneous) return next()
isLinkable(pkg, function (install, link) {
if (install) linkTodoList.push(['global-install', pkg])
if (link) linkTodoList.push(['global-link', pkg])
- if (install || link) {
- pkg.parent.children = pkg.parent.children.filter(function (child) { return child !== pkg })
- }
+ if (install || link) removeObsoleteDep(pkg)
next()
})
}, function () {
if (linkTodoList.length === 0) return cb()
- pruneTree(self.idealTree)
self.differences.length = 0
Array.prototype.push.apply(self.differences, linkTodoList)
diffTrees(self.currentTree, self.idealTree, self.differences, log.newGroup('d2'), cb)
@@ -633,8 +631,8 @@ Installer.prototype.normalizeTree = function (log, cb) {
log.silly('install', 'normalizeTree')
recalculateMetadata(this.currentTree, log, iferr(cb, function (tree) {
tree.children.forEach(function (child) {
- if (child.package._requiredBy.length === 0) {
- child.package._requiredBy.push('#EXISTING')
+ if (child.requiredBy.length === 0) {
+ child.existing = true
}
})
cb(null, tree)
@@ -655,17 +653,16 @@ Installer.prototype.printInstalled = function (cb) {
validate('F', arguments)
log.silly('install', 'printInstalled')
var self = this
- log.clearProgress()
this.differences.forEach(function (action) {
var mutation = action[0]
var child = action[1]
var name = packageId(child)
var where = path.relative(self.where, child.path)
if (mutation === 'remove') {
- console.log('- ' + name + ' ' + where)
+ output('- ' + name + ' ' + where)
} else if (mutation === 'move') {
var oldWhere = path.relative(self.where, child.fromPath)
- console.log(name + ' ' + oldWhere + ' -> ' + where)
+ output(name + ' ' + oldWhere + ' -> ' + where)
}
})
var addedOrMoved = this.differences.filter(function (action) {
@@ -676,10 +673,9 @@ Installer.prototype.printInstalled = function (cb) {
var child = action[1]
return child.path
})
- log.showProgress()
if (!addedOrMoved.length) return cb()
+ // TODO: remove the recalculateMetadata, should not be needed
recalculateMetadata(this.idealTree, log, iferr(cb, function (tree) {
- log.clearProgress()
// These options control both how installs happen AND how `ls` shows output.
// Something like `npm install --production` only installs production deps.
// By contrast `npm install --production foo` installs `foo` and the
@@ -691,10 +687,7 @@ Installer.prototype.printInstalled = function (cb) {
npm.config.set('dev', false)
npm.config.set('only', '')
npm.config.set('also', '')
- ls.fromTree(self.where, tree, addedOrMoved, false, function () {
- log.showProgress()
- cb()
- })
+ ls.fromTree(self.where, tree, addedOrMoved, false, andIgnoreErrors(cb))
}))
}