cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [1/2] cordova-wp8 git commit: CB-8310: Fix to cordova run wp8 to attempt to deploy to device before it tries to deploy to emulator
Date Tue, 20 Jan 2015 21:56:04 GMT
Repository: cordova-wp8
Updated Branches:
  refs/heads/master 02c42e82a -> a08fb7f6d


CB-8310: Fix to cordova run wp8 to attempt to deploy to device before it tries to deploy to
emulator


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

Branch: refs/heads/master
Commit: b2168c8294d91b12b1532656ad781c722d144c19
Parents: 4ea3410
Author: Nikhil Khandelwal <nikhilkh@microsoft.com>
Authored: Wed Jan 14 15:08:36 2015 -0800
Committer: Nikhil Khandelwal <nikhilkh@microsoft.com>
Committed: Fri Jan 16 17:22:23 2015 -0800

----------------------------------------------------------------------
 template/cordova/lib/run.js | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/b2168c82/template/cordova/lib/run.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/run.js b/template/cordova/lib/run.js
index c179ced..e9d3be8 100644
--- a/template/cordova/lib/run.js
+++ b/template/cordova/lib/run.js
@@ -27,7 +27,7 @@ var Q = require('q'),
 var ROOT = path.join(__dirname, '..', '..');
 
 module.exports.run = function (argv) {
-    if (!utils.isCordovaProject(ROOT)){
+    if (!utils.isCordovaProject(ROOT)) {
         return Q.reject("Could not find project at " + ROOT);
     }
 
@@ -46,20 +46,32 @@ module.exports.run = function (argv) {
 
     // Get build/deploy options
     var buildType    = args.release ? "release" : "debug",
-        buildArchs   = args.archs ? args.archs.split(' ') : ["anycpu"],
-        deployTarget = args.target ? args.target : args.device ? "device" : "emulator";
+        buildArchs   = args.archs ? args.archs.split(' ') : ["anycpu"];
 
     // if --nobuild isn't specified then build app first
     var buildPackages = args.nobuild ? Q() : build.run(argv);
 
     return buildPackages
-    .then(function () {
-        return packages.getPackage(buildType, buildArchs[0]);
-    })
-    .then(function(builtPackage) {
-        console.log('\nDeploying package to ' + deployTarget);
-        return builtPackage.deployTo(deployTarget);
-    });
+        .then(function () {
+            return packages.getPackage(buildType, buildArchs[0]);
+        })
+        .then(function (builtPackage) {
+            // Get deploy options
+            var deployTarget = args.target ? args.target : args.device ? "device" : 
+                args.emulator ? "emulator" : null;
+
+            if (deployTarget) {
+                console.log('\nDeploying package to ' + deployTarget);
+                return builtPackage.deployTo(deployTarget);
+            }
+            // no deploy target specified - try device first & then emulator
+            console.log("\nTrying to deploy to device");
+            return builtPackage.deployTo("device").catch(function (error) {
+                console.log(error);
+                console.log("\nFalling back to deploy to emulator instead");
+                return builtPackage.deployTo("emulator");
+            });
+        });
 };
 
 module.exports.help = function () {


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


Mime
View raw message