cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [1/3] android commit: CB-8168 Add support for `cordova/run --list` (closes #139)
Date Sun, 04 Jan 2015 02:06:23 GMT
Repository: cordova-android
Updated Branches:
  refs/heads/4.0.x 61c4bb988 -> 95e10bdb9
  refs/heads/master 343974664 -> c2a6dcb6b


CB-8168 Add support for `cordova/run --list` (closes #139)


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

Branch: refs/heads/4.0.x
Commit: c2a6dcb6bd98ae8060ef839d403bfd764047bdfa
Parents: 3439746
Author: Murat Sutunc <muratsu@microsoft.com>
Authored: Mon Dec 29 11:43:46 2014 -0800
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Sat Jan 3 21:05:52 2015 -0500

----------------------------------------------------------------------
 bin/templates/cordova/lib/run.js | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c2a6dcb6/bin/templates/cordova/lib/run.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/run.js b/bin/templates/cordova/lib/run.js
index 024fcd0..12f178c 100644
--- a/bin/templates/cordova/lib/run.js
+++ b/bin/templates/cordova/lib/run.js
@@ -23,11 +23,12 @@ var path  = require('path'),
     build = require('./build'),
     emulator = require('./emulator'),
     device   = require('./device'),
+    shell = require('shelljs'),
     Q = require('q');
 
 /*
  * Runs the application on a device if available.
- * If not device is found, it will use a started emulator.
+ * If no device is found, it will use a started emulator.
  * If no started emulators are found it will attempt to start an avd.
  * If no avds are found it will error out.
  * Returns a promise.
@@ -35,6 +36,7 @@ var path  = require('path'),
  module.exports.run = function(args) {
     var buildFlags = [];
     var install_target;
+    var list = false;
 
     for (var i=2; i<args.length; i++) {
         if (args[i] == '--debug') {
@@ -49,12 +51,41 @@ var path  = require('path'),
             install_target = '--emulator';
         } else if (args[i].substring(0, 9) == '--target=') {
             install_target = args[i].substring(9, args[i].length);
+        } else if (args[i] == '--list') {
+            list = true;
         } else {
             console.error('ERROR : Run option \'' + args[i] + '\' not recognized.');
             process.exit(2);
         }
     }
 
+    if (list) {
+        var output = '';
+        var temp = '';
+        if (!install_target) {
+            output += 'Available Android Devices:\n';
+            temp = shell.exec(path.join(__dirname, 'list-devices'), {silent:true}).output;
+            temp = temp.replace(/^(?=[^\s])/gm, '\t');
+            output += temp;
+            output += 'Available Android Virtual Devices:\n';
+            temp = shell.exec(path.join(__dirname, 'list-emulator-images'), {silent:true}).output;
+            temp = temp.replace(/^(?=[^\s])/gm, '\t');
+            output += temp;
+        } else if (install_target == '--emulator') {
+            output += 'Available Android Virtual Devices:\n';
+            temp = shell.exec(path.join(__dirname, 'list-emulator-images'), {silent:true}).output;
+            temp = temp.replace(/^(?=[^\s])/gm, '\t');
+            output += temp;
+        } else if (install_target == '--device') {
+            output += 'Available Android Devices:\n';
+            temp = shell.exec(path.join(__dirname, 'list-devices'), {silent:true}).output;
+            temp = temp.replace(/^(?=[^\s])/gm, '\t');
+            output += temp;
+        }
+        console.log(output);
+        return;
+    }
+
     return Q()
     .then(function() {
         if (!install_target) {


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


Mime
View raw message