cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhigg...@apache.org
Subject [2/2] webworks commit: [CB-4268] Add support for --device and --emulator to run script
Date Wed, 17 Jul 2013 17:15:25 GMT
[CB-4268] Add support for --device and --emulator to run script


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

Branch: refs/heads/3.0.x
Commit: d273506c8a0a6079617eb4e0d50e0f9507adf414
Parents: 698d188
Author: Bryan Higgins <bhiggins@blackberry.com>
Authored: Wed Jul 17 08:47:28 2013 -0400
Committer: Bryan Higgins <bhiggins@blackberry.com>
Committed: Wed Jul 17 13:15:58 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/cordova/lib/run       | 57 +++++++++++++++-----
 1 file changed, 44 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/d273506c/blackberry10/bin/templates/project/cordova/lib/run
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/run b/blackberry10/bin/templates/project/cordova/lib/run
index 097a73a..0d57afd 100755
--- a/blackberry10/bin/templates/project/cordova/lib/run
+++ b/blackberry10/bin/templates/project/cordova/lib/run
@@ -23,6 +23,7 @@ var childProcess = require("child_process"),
     wrench = require("wrench"),
     conf = require("./conf"),
     utils = require("./utils"),
+    targetUtils = require("./target-utils.js"),
     localize = require("./localize"),
     pkgrUtils = require("./packager-utils"),
     debugTokenHelper = require("./debugtoken-helper"),
@@ -95,6 +96,35 @@ function execNativeDeploy(optionsArray, callback) {
     });
 }
 
+function setTarget(callback) {
+    target = program.args[0] ? program.args[0] : targets.defaultTarget;
+    if (program["device"]) {
+        targetUtils.getTargetList("device", true, function (targets) {
+            if (targets && targets.length > 0) {
+                target = targets[0].name;
+                callback();
+            } else {
+                console.error("No connected device found");
+                console.error("Devices must first be configured using platforms/blackberry/cordova/target");

+                process.exit(1);
+            }
+        });
+    } else if (program["emulator"]) {
+        targetUtils.getTargetList("simulator", true, function (targets) {
+            if (targets && targets.length > 0) { 
+                target = targets[0].name;
+                callback();
+            } else {
+                console.error("No connected BB10 simulator found");
+                console.error("Simulators must first be configured using platforms/blackberry/cordova/target");
+                process.exit(1);
+            }
+        });
+    } else {
+        callback();
+    }
+}
+
 function checkTarget() {
     if (!target) {
         console.log("No target exists, to add that target please run target add <name>
<ip> [-t | --type <device | simulator>] [-p <password>] [--pin <devicepin>]");
@@ -273,22 +303,23 @@ function exec() {
     }
 
     program.parse(process.argv);
-    target = program.args[0] ? program.args[0] : targets.defaultTarget;
 
-    if (checkTarget()) {
-        if (program.build) {
-            jWorkflow.order(checkDebugtoken)
-                     .andThen(createDebugToken)
-                     .andThen(deployDebugToken)
-                     .andThen(build)
-                     .andThen(postBuild)
-                     .start();
+    setTarget(function () {
+        if (checkTarget()) {
+            if (program.build) {
+                jWorkflow.order(checkDebugtoken)
+                    .andThen(createDebugToken)
+                    .andThen(deployDebugToken)
+                    .andThen(build)
+                    .andThen(postBuild)
+                    .start();
+            } else {
+                postBuild();
+            }
         } else {
-            postBuild();
+            process.exit(1);
         }
-    } else {
-        process.exit(1);
-    }
+    });
 }
 
 exec();


Mime
View raw message