cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject git commit: CB-7820 Make cordova platfrom restore not stop if a platforms fails to restore
Date Tue, 21 Oct 2014 17:20:33 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master 272fad91e -> 64b236af5


CB-7820 Make cordova platfrom restore not stop if a platforms fails to restore

handles restoration for each platform separately so that if one fails installation for
others continues. Also makes a change on how the host is checked to allow such errors
not to completely halt the execution.

close #106


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/64b236af
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/64b236af
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/64b236af

Branch: refs/heads/master
Commit: 64b236af58ac85bde0ddaec96463fc25a12dab7e
Parents: 272fad9
Author: Gorkem Ercan <gorkem.ercan@gmail.com>
Authored: Sat Oct 18 18:27:43 2014 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Oct 21 13:19:20 2014 -0400

----------------------------------------------------------------------
 cordova-lib/src/cordova/platform.js | 10 +++++-----
 cordova-lib/src/cordova/restore.js  | 16 +++++++++++++++-
 2 files changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/64b236af/cordova-lib/src/cordova/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/platform.js b/cordova-lib/src/cordova/platform.js
index 1a8ab3c..85eda0a 100644
--- a/cordova-lib/src/cordova/platform.js
+++ b/cordova-lib/src/cordova/platform.js
@@ -54,13 +54,13 @@ function add(hooksRunner, projectRoot, targets, opts) {
         return Q.reject(new CordovaError(msg));
     }
 
-    targets.forEach(function(platform) {
-        if ( !hostSupports(platform) ) {
-            msg = 'Applications for platform ' + platform +
+    for(var i= 0 ; i< targets.length; i++){
+        if ( !hostSupports(targets[i]) ) {
+            msg = 'Applications for platform ' + targets[i] +
                   ' can not be built on this OS - ' + process.platform + '.';
-            throw new CordovaError(msg);
+            return Q.reject( new CordovaError(msg));
         }
-    });
+    }
 
     var xml = cordova_util.projectConfig(projectRoot);
     var cfg = new ConfigParser(xml);

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/64b236af/cordova-lib/src/cordova/restore.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/restore.js b/cordova-lib/src/cordova/restore.js
index 39d2ee9..eff7055 100644
--- a/cordova-lib/src/cordova/restore.js
+++ b/cordova-lib/src/cordova/restore.js
@@ -54,7 +54,21 @@ function installPlatformsFromConfigXML(cfg){
     if(!targets || !targets.length  ){
         return Q.all('No platforms are listed in config.xml to restore');
     }
-    return platform('add', targets);
+    
+    // Run platform add for all the platforms seperately 
+    // so that failure on one does not affect the other.
+    var promises = targets.map(function(target){
+        return platform('add',target);
+    });
+    return Q.allSettled(promises).then(
+        function (results) {
+            for(var i =0; i<results.length; i++){
+                //log the rejections otherwise they are lost
+                if(results[i].state ==='rejected'){
+                    events.emit('log', results[i].reason.message);
+                }
+            }
+        });
 }
 
 //returns a Promise


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message