mirror of
https://github.com/bower/bower.git
synced 2026-04-24 03:00:19 -04:00
Improve doc blocks and minor bug fixing.
This commit is contained in:
@@ -56,7 +56,9 @@ Manager.prototype.configure = function (setup) {
|
||||
var target;
|
||||
|
||||
// Skip if it's a target
|
||||
target = mout.array.find(this._targets, mout.object.equals.bind(mout, decEndpoint));
|
||||
target = mout.array.find(this._targets, function (target) {
|
||||
return mout.object.equals(decEndpoint, target);
|
||||
});
|
||||
if (!target) {
|
||||
this._incompatibles[name] = this._incompatibles[name] || [];
|
||||
this._incompatibles[name].push(decEndpoint);
|
||||
@@ -147,6 +149,7 @@ Manager.prototype.install = function () {
|
||||
return Q.all(promises);
|
||||
})
|
||||
.then(function () {
|
||||
// Resolve with meaningful data
|
||||
return mout.object.map(that._dissected, function (decEndpoint) {
|
||||
var data = this._toData(decEndpoint);
|
||||
data.dependencies = mout.object.map(decEndpoint.dependencies, this._toData, this);
|
||||
@@ -163,7 +166,7 @@ Manager.prototype.areCompatible = function (candidate, resolved) {
|
||||
var highestCandidate;
|
||||
var highestResolved;
|
||||
|
||||
// Check If targets are equal
|
||||
// Check if targets are equal
|
||||
if (candidate.target === resolved.target) {
|
||||
return true;
|
||||
}
|
||||
@@ -179,6 +182,7 @@ Manager.prototype.areCompatible = function (candidate, resolved) {
|
||||
}
|
||||
|
||||
// If target is a range, check if the max versions of the range are the same
|
||||
// and if the resolved version satisfies the candidate target
|
||||
if (semver.validRange(candidate.target) != null) {
|
||||
highestCandidate = this._getCap(semver.toComparators(candidate.target), 'highest');
|
||||
highestResolved = this._getCap(semver.toComparators(resolved.target), 'highest');
|
||||
@@ -213,8 +217,6 @@ Manager.prototype._fetch = function (decEndpoint) {
|
||||
// When done, call onFetchSuccess
|
||||
.spread(this._onFetchSuccess.bind(this, decEndpoint))
|
||||
// If it fails, call onFetchFailure
|
||||
// Note that any sync error that happens on the _onFetchSuccess
|
||||
// will cause this function to be called
|
||||
.fail(this._onFetchError.bind(this, decEndpoint));
|
||||
};
|
||||
|
||||
@@ -269,8 +271,8 @@ Manager.prototype._onFetchSuccess = function (decEndpoint, canonicalPkg, pkgMeta
|
||||
delete this._incompatibles[name];
|
||||
}
|
||||
|
||||
// If the resolve process ended, parse the resolved packages
|
||||
// to find the most suitable version for each package
|
||||
// If there are no more packages being fetched,
|
||||
// finish the resolve process by dissecting all resolved packages
|
||||
if (this._nrFetching <= 0) {
|
||||
process.nextTick(this._dissect.bind(this));
|
||||
}
|
||||
@@ -294,8 +296,8 @@ Manager.prototype._onFetchError = function (decEndpoint, err) {
|
||||
// Make the whole process to fail fast
|
||||
this._failFast();
|
||||
|
||||
// If the resolve process ended, parse the resolved packages
|
||||
// to find the most suitable version for each package
|
||||
// If there are no more packages being fetched,
|
||||
// finish the resolve process (with an error)
|
||||
if (this._nrFetching <= 0) {
|
||||
process.nextTick(this._dissect.bind(this));
|
||||
}
|
||||
@@ -308,7 +310,7 @@ Manager.prototype._failFast = function () {
|
||||
|
||||
this._hasFailed = true;
|
||||
|
||||
// If after 20 seconds all pending tasks haven't finished,
|
||||
// If after some amount of time all pending tasks haven't finished,
|
||||
// we force the process to end
|
||||
this._failFastTimeout = setTimeout(function () {
|
||||
this._nrFetching = Infinity;
|
||||
@@ -397,6 +399,7 @@ Manager.prototype._dissect = function () {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find a suitable version for each package name
|
||||
mout.object.forOwn(this._resolved, function (decEndpoints, name) {
|
||||
var semvers;
|
||||
var nonSemvers;
|
||||
@@ -424,11 +427,11 @@ Manager.prototype._dissect = function () {
|
||||
});
|
||||
}, this);
|
||||
|
||||
// After a suitable version has been elected for every package
|
||||
promise
|
||||
.then(function () {
|
||||
// Look for extraneous resolutions
|
||||
mout.object.forOwn(this._resolutions, function (resolution, name) {
|
||||
// If if conflicted, then it was used
|
||||
if (this._conflicted[name]) {
|
||||
return;
|
||||
}
|
||||
@@ -446,15 +449,12 @@ Manager.prototype._dissect = function () {
|
||||
this._dissected = mout.object.filter(suitables, function (decEndpoint, name) {
|
||||
var installedMeta = this._installed[name];
|
||||
|
||||
if (!installedMeta) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !installedMeta ||
|
||||
installedMeta._release !== decEndpoint.pkgMeta._release ||
|
||||
installedMeta._target !== decEndpoint.target;
|
||||
}, this);
|
||||
|
||||
// Resolve with meaningful data
|
||||
return mout.object.map(this._dissected, function (decEndpoint) {
|
||||
var data = this._toData(decEndpoint);
|
||||
data.dependencies = mout.object.map(decEndpoint.dependencies, this._toData, this);
|
||||
|
||||
@@ -57,10 +57,10 @@ Project.prototype.install = function (endpoints, options) {
|
||||
if (endpoints) {
|
||||
endpoints.forEach(function (endpoint) {
|
||||
var decEndpoint = endpointParser.decompose(endpoint);
|
||||
// Mark as unresolvable so that a conflict for this target always require
|
||||
// a choice
|
||||
decEndpoint.unresolvable = true;
|
||||
targets.push(decEndpoint);
|
||||
// Mark as unresolvable so that a conflict for
|
||||
// this target always require a choice
|
||||
decEndpoint.unresolvable = true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,8 +70,6 @@ Project.prototype.install = function (endpoints, options) {
|
||||
.then(function (installed) {
|
||||
// Handle save and saveDev options
|
||||
if (options.save || options.saveDev) {
|
||||
// Cycle through the initial targets and not the installed
|
||||
// ones because some targets could already be installed
|
||||
mout.object.forOwn(targets, function (decEndpoint) {
|
||||
var source = decEndpoint.registry ? '' : decEndpoint.source;
|
||||
var target = decEndpoint.target;
|
||||
@@ -89,8 +87,7 @@ Project.prototype.install = function (endpoints, options) {
|
||||
});
|
||||
}
|
||||
|
||||
// Save JSON, might contain changes to dependencies
|
||||
// and resolutions
|
||||
// Save JSON, might contain changes to dependencies and resolutions
|
||||
return that._saveJson()
|
||||
.then(function () {
|
||||
return installed;
|
||||
@@ -126,7 +123,7 @@ Project.prototype.update = function (names, options) {
|
||||
that._walkTree(tree, function (node) {
|
||||
targets.push(node);
|
||||
return false;
|
||||
});
|
||||
}, true);
|
||||
|
||||
// Mark extraneous as targets
|
||||
mout.object.forOwn(flattened, function (decEndpoint) {
|
||||
@@ -136,6 +133,16 @@ Project.prototype.update = function (names, options) {
|
||||
});
|
||||
// Otherwise, selectively update the specified ones
|
||||
} else {
|
||||
// Error out if some of the specified names
|
||||
// are not installed
|
||||
names.forEach(function (name) {
|
||||
if (!flattened[name]) {
|
||||
throw createError('Package ' + name + ' is not installed', 'ENOTINS', {
|
||||
name: name
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Walk down the tree adding missing, incompatible
|
||||
// and resolved
|
||||
that._walkTree(tree, function (node, name) {
|
||||
@@ -148,35 +155,19 @@ Project.prototype.update = function (names, options) {
|
||||
}
|
||||
}, true);
|
||||
|
||||
// Add root packages that match the name as targets
|
||||
// Add root packages whose names are specified to be updated
|
||||
that._walkTree(tree, function (node, name) {
|
||||
if (names.indexOf(name) !== -1) {
|
||||
if (!node.missing && names.indexOf(name) !== -1) {
|
||||
targets.push(node);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}, true);
|
||||
|
||||
// Mark extraneous that match the name as targets
|
||||
// Mark extraneous whose names are specified to be updated
|
||||
mout.object.forOwn(flattened, function (decEndpoint, name) {
|
||||
if (decEndpoint.extraneous && names.indexOf(name) !== -1) {
|
||||
targets.push(decEndpoint);
|
||||
}
|
||||
});
|
||||
|
||||
// Error out if some of the names were not found
|
||||
names.forEach(function (name) {
|
||||
var foundTarget;
|
||||
|
||||
foundTarget = !!mout.array.find(targets, function (target) {
|
||||
return target.name === name;
|
||||
});
|
||||
|
||||
if (!foundTarget) {
|
||||
throw createError('Package ' + name + ' is not installed', 'ENOTINS', {
|
||||
name: name
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Bootstrap the process
|
||||
|
||||
Reference in New Issue
Block a user