Add linked reps as resolved to prevent them for being overwritten in common usages, #593.

This commit is contained in:
André Cruz
2013-07-29 09:05:53 +01:00
parent 063453b744
commit ee76fe584e
2 changed files with 41 additions and 20 deletions

View File

@@ -128,14 +128,10 @@ Manager.prototype.install = function () {
var dst;
var release = decEndpoint.pkgMeta._release;
// Skip if source is the same as dest
dst = path.join(componentsDir, name);
if (dst === decEndpoint.canonicalDir) {
return;
}
that._logger.action('install', name + (release ? '#' + release : ''), that.toData(decEndpoint));
dst = path.join(componentsDir, name);
// Remove existent and copy canonical dir
promise = Q.nfcall(rimraf, dst)
.then(copy.copyDir.bind(copy, decEndpoint.canonicalDir, dst))
@@ -417,6 +413,7 @@ Manager.prototype._parseDependencies = function (decEndpoint, pkgMeta, jsonKey)
Manager.prototype._dissect = function () {
var err;
var componentsDir;
var promise = Q.resolve();
var suitables = {};
var that = this;
@@ -501,13 +498,27 @@ Manager.prototype._dissect = function () {
}, this);
// Filter only packages that need to be installed
componentsDir = path.resolve(that._config.cwd, that._config.directory);
this._dissected = mout.object.filter(suitables, function (decEndpoint, name) {
var installedMeta = this._installed[name];
var target = decEndpoint.target;
var dst;
return !installedMeta ||
installedMeta._target !== target ||
installedMeta._release !== decEndpoint.pkgMeta._release;
// Analyse a few props
if (installedMeta &&
installedMeta._target === target &&
installedMeta._release === decEndpoint.pkgMeta._release
) {
return false;
}
// Skip if source is the same as dest
dst = path.join(componentsDir, name);
if (dst === decEndpoint.canonicalDir) {
return false;
}
return true;
}, this);
// Resolve with meaningful data
@@ -545,15 +556,14 @@ Manager.prototype._electSuitable = function (name, semvers, nonSemvers) {
} else {
suitable = mout.array.find(semvers, function (subject) {
return semvers.every(function (decEndpoint) {
return semver.satisfies(subject.pkgMeta.version, decEndpoint.target);
return subject === decEndpoint ||
semver.satisfies(subject.pkgMeta.version, decEndpoint.target);
});
});
if (suitable) {
return Q.resolve(suitable);
}
picks.push.apply(picks, semvers);
}
// At this point, there's a conflict

View File

@@ -54,6 +54,12 @@ Project.prototype.install = function (endpoints, options) {
} else {
resolved[name] = node;
}
// Ignore linked dependencies because it's too complex to parse them
// Note that this might change in the future: #673
if (node.linked) {
return false;
}
}, true);
// Add endpoints as targets
@@ -168,6 +174,12 @@ Project.prototype.update = function (names, options) {
} else {
resolved[name] = node;
}
// Ignore linked dependencies because it's too complex to parse them
// Note that this might change in the future: #673
if (node.linked) {
return false;
}
}, true);
}
@@ -382,13 +394,6 @@ Project.prototype.walkTree = function (node, fn, onlyOnce) {
while (queue.length) {
node = queue.shift();
// Ignore linked dependencies because it's too complex to parse them
// Note that this might change in the future: #673
if (node.linked) {
continue;
}
result = fn(node, node.name);
// Abort traversal if result is false
@@ -396,6 +401,12 @@ Project.prototype.walkTree = function (node, fn, onlyOnce) {
continue;
}
// Ignore linked dependencies because it's too complex to parse them
// Note that this might change in the future: #673
if (node.linked) {
continue;
}
// Add dependencies to the queue
dependencies = mout.object.values(node.dependencies);
@@ -619,7 +630,7 @@ Project.prototype._readLinks = function () {
decEndpoints[name] = {
name: name,
source: dir,
target: pkgMeta.version ? '~' + pkgMeta.version : '*',
target: '*',
canonicalDir: dir,
pkgMeta: pkgMeta,
linked: true