cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [04/15] git commit: add emulator support
Date Tue, 26 Aug 2014 20:46:37 GMT
add emulator support


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

Branch: refs/heads/master
Commit: 11e4cf2d9a0d996832ed1929f0f53a3cd11f3f40
Parents: 2902609
Author: Maxim Ermilov <maxim.ermilov@canonical.com>
Authored: Mon Jun 2 19:51:49 2014 +0400
Committer: Maxim Ermilov <maxim.ermilov@canonical.com>
Committed: Tue Aug 19 14:19:12 2014 +0400

----------------------------------------------------------------------
 bin/build/lib/msg.js    |  3 ++-
 bin/build/lib/ubuntu.js | 42 ++++++++++++++++++++++++++----------------
 bin/build/run           |  4 ++--
 3 files changed, 30 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/11e4cf2d/bin/build/lib/msg.js
----------------------------------------------------------------------
diff --git a/bin/build/lib/msg.js b/bin/build/lib/msg.js
index d45eb61..6125aa5 100644
--- a/bin/build/lib/msg.js
+++ b/bin/build/lib/msg.js
@@ -20,5 +20,6 @@
 */
 
 module.exports = {
-    UBUNTU_TOUCH_DEVICE_NOT_AVALIABLE: 'UbuntuTouch device is not attached'
+    UBUNTU_TOUCH_DEVICE_NOT_AVALIABLE: 'UbuntuTouch device is not attached',
+    EMULATOR_IS_NOT_RUNNING: 'UbuntuTouch emulator is not running'
 };

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/11e4cf2d/bin/build/lib/ubuntu.js
----------------------------------------------------------------------
diff --git a/bin/build/lib/ubuntu.js b/bin/build/lib/ubuntu.js
index ae18659..b7f5ed2 100644
--- a/bin/build/lib/ubuntu.js
+++ b/bin/build/lib/ubuntu.js
@@ -314,33 +314,43 @@ function runOnDevice(rootDir, debug, target, architecture) {
     });
 }
 
-module.exports.run = function(rootDir, desktop, debug, target, nobuild) {
-    if (desktop) {
+module.exports.run = function(rootDir, desktop, debug, target, nobuild, emulator) {
+    if (desktop && !emulator) {
         return module.exports.build(rootDir, module.exports.DESKTOP, nobuild).then(function
() {
             return runNative(rootDir, debug);
         });
-    } else {
-        if (!target) {
-            var devices = deviceList();
+    }
+
+    if (!target) {
+        var devices = deviceList();
+
+        if (!devices.length) {
+            console.error(msg.UBUNTU_TOUCH_DEVICE_NOT_AVALIABLE.red)
+            process.exit(1);
+        }
 
+        if (emulator) {
+            devices = devices.filter(function (name) {
+                return name.match(/^emulator-/);
+            });
             if (!devices.length) {
-                console.error(msg.UBUNTU_TOUCH_DEVICE_NOT_AVALIABLE.red)
+                console.error(msg.EMULATOR_IS_NOT_RUNNING.red)
                 process.exit(1);
             }
+        }
 
-            target = devices[0];
+        target = devices[0];
 
-            if (devices.length > 1) {
-                console.warn('you can specify target with --target <device id>'.yellow);
-                console.warn(('running on ' + target).yellow);
-            }
+        if (devices.length > 1) {
+            console.warn('you can specify target with --target <device id>'.yellow);
+            console.warn(('running on ' + target).yellow);
         }
-        var arch = getDeviceArch(target);
-
-        return module.exports.build(rootDir, module.exports.PHONE, nobuild, arch).then(function
() {
-             return runOnDevice(rootDir, debug, target, arch);
-        });
     }
+    var arch = getDeviceArch(target);
+
+    return module.exports.build(rootDir, module.exports.PHONE, nobuild, arch).then(function
() {
+        return runOnDevice(rootDir, debug, target, arch);
+    });
 }
 
 module.exports.check_reqs = function(rootDir) {

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/11e4cf2d/bin/build/run
----------------------------------------------------------------------
diff --git a/bin/build/run b/bin/build/run
index 923171d..a69b28a 100755
--- a/bin/build/run
+++ b/bin/build/run
@@ -24,9 +24,9 @@ var platform = require('./lib/ubuntu');
 var root = path.resolve();
 var www = path.join(root, 'www');
 
-var argv = require('optimist').boolean(['device', 'debug', 'nobuild']).string(['target']).argv;
+var argv = require('optimist').boolean(['device', 'emulator', 'debug', 'nobuild']).string(['target']).argv;
 
 platform.check_reqs(root).then(function () {
-    return platform.run(root, !argv.device, argv.debug, argv.target, argv.nobuild);
+    return platform.run(root, !argv.device, argv.debug, argv.target, argv.nobuild, argv.emulator);
 }).done();
 


Mime
View raw message