This commit is contained in:
André Cruz
2013-05-30 22:32:21 +01:00
parent 76b85ed554
commit 26da7d5e81

View File

@@ -21,6 +21,9 @@ function Project(config) {
Project.prototype.install = function (endpoints, options) {
var that = this;
var targets = {};
var resolved = {};
var installed;
// If already working, error out
if (this._working) {
@@ -68,32 +71,33 @@ Project.prototype.install = function (endpoints, options) {
installed = mout.object.map(flattened, function (decEndpoint) {
return decEndpoint.pkgMeta;
});
})
// Bootstrap the process
.then(function () {
return that._bootstrap(targets, resolved, installed);
})
// Handle save and saveDev options
.then(function (installed) {
var jsonKey;
// Bootstrap the process
return that._bootstrap(targets, resolved, installed)
// Handle save and saveDev options
.then(function (installed) {
var jsonKey;
if (!options.save && !options.saveDev) {
return;
}
if (!options.save && !options.saveDev) {
return;
}
jsonKey = options.save ? 'dependencies' : 'devDependencies';
that._json[jsonKey] = that._json[jsonKey] || {};
jsonKey = options.save ? 'dependencies' : 'devDependencies';
that._json[jsonKey] = that._json[jsonKey] || {};
mout.object.forOwn(targets, function (decEndpoint) {
var source = decEndpoint.registry ? '' : decEndpoint.source;
var target = decEndpoint.pkgMeta.version ? '~' + decEndpoint.pkgMeta.version : decEndpoint.target;
that._json[jsonKey][decEndpoint.name] = mout.string.ltrim(source + '#' + target, ['#']);
});
mout.object.forOwn(targets, function (decEndpoint) {
var source = decEndpoint.registry ? '' : decEndpoint.source;
var target = decEndpoint.pkgMeta.version ? '~' + decEndpoint.pkgMeta.version : decEndpoint.target;
that._json[jsonKey][decEndpoint.name] = mout.string.ltrim(source + '#' + target, ['#']);
});
return that._saveJson()
.then(function () {
return installed;
}, null, function (notification) {
return notification;
});
return that._saveJson()
.then(function () {
return installed;
}, null, function (notification) {
return notification;
});
})
.fin(function () {
@@ -186,7 +190,7 @@ Project.prototype.update = function (names, options) {
});
}
// Bootstrap the process
// Bootstrap the process
return promise.then(function () {
return that._bootstrap(targets, resolved, installed);
})