You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/09/13 01:35:51 UTC
[10/16] git commit: [CB-4325] Run platform installs in serial instead
of in parallel
[CB-4325] Run platform installs in serial instead of in parallel
Now a failure in one doesn't leave others in a bad state.
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/cc30eaca
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/cc30eaca
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/cc30eaca
Branch: refs/heads/ffos
Commit: cc30eaca3d53892e6d27751eb9ee30aba32d1582
Parents: 7270f33
Author: Braden Shepherdson <br...@gmail.com>
Authored: Fri Sep 6 08:57:46 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Fri Sep 6 08:57:46 2013 -0400
----------------------------------------------------------------------
src/platform.js | 50 +++++++++++++++++++++++++++++++-------------------
1 file changed, 31 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/cc30eaca/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index fea9a64..214c78d 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -69,36 +69,48 @@ module.exports = function platform(command, targets, callback) {
switch(command) {
case 'add':
- var end = n(targets.length, function() {
- hooks.fire('after_platform_add', opts, function(err) {
+ var config_json = config.read(projectRoot);
+
+ var doInstall = function(index) {
+ if (index >= targets.length) {
+ hooks.fire('after_platform_add', opts, function(err) {
+ if (err) {
+ if (callback) callback(err);
+ else throw err;
+ } else {
+ if (callback) callback();
+ }
+ });
+ return;
+ }
+
+ var t = targets[index];
+ lazy_load.based_on_config(projectRoot, t, function(err) {
if (err) {
if (callback) callback(err);
else throw err;
} else {
- if (callback) callback();
+ if (config_json.lib && config_json.lib[t]) {
+ call_into_create(t, projectRoot, cfg, config_json.lib[t].id, config_json.lib[t].version, config_json.lib[t].template, callback, end(index));
+ } else {
+ call_into_create(t, projectRoot, cfg, 'cordova', platforms[t].version, null, callback, end(index));
+ }
}
});
- });
+ };
+
+ var end = function(index) {
+ return function() {
+ doInstall(index+1);
+ };
+ };
+
hooks.fire('before_platform_add', opts, function(err) {
if (err) {
if (callback) callback(err);
else throw err;
} else {
- var config_json = config.read(projectRoot);
- targets.forEach(function(t) {
- lazy_load.based_on_config(projectRoot, t, function(err) {
- if (err) {
- if (callback) callback(err);
- else throw err;
- } else {
- if (config_json.lib && config_json.lib[t]) {
- call_into_create(t, projectRoot, cfg, config_json.lib[t].id, config_json.lib[t].version, config_json.lib[t].template, callback, end);
- } else {
- call_into_create(t, projectRoot, cfg, 'cordova', platforms[t].version, null, callback, end);
- }
- }
- });
- });
+ doInstall(0);
}
});
break;