You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by db...@apache.org on 2016/01/13 23:25:13 UTC

cordova-medic git commit: Made medic-log bail out unless there is exactly one Android device available.

Repository: cordova-medic
Updated Branches:
  refs/heads/master c66fbcacd -> c58110613


Made medic-log bail out unless there is exactly one Android device available.


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

Branch: refs/heads/master
Commit: c58110613104ef1bb78365235ab75845f58a40e1
Parents: c66fbca
Author: Dmitry Blotsky <dm...@gmail.com>
Authored: Wed Jan 13 14:23:29 2016 -0800
Committer: Dmitry Blotsky <dm...@gmail.com>
Committed: Wed Jan 13 14:23:29 2016 -0800

----------------------------------------------------------------------
 medic/medic-log.js | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/c5811061/medic/medic-log.js
----------------------------------------------------------------------
diff --git a/medic/medic-log.js b/medic/medic-log.js
index 5251898..d793259 100644
--- a/medic/medic-log.js
+++ b/medic/medic-log.js
@@ -30,15 +30,34 @@ var path     = require("path");
 
 var util = require("../lib/util");
 
+// constants
+var DEVICE_ROW_PATTERN = / (emulator|device|host) /m;
+
 // helpers
 function logAndroid() {
 
-    var command = "adb logcat -d";
+    var logCommand = "adb logcat -d";
+    var listCommand = "adb devices";
 
     util.medicLog("running:");
-    util.medicLog("    " + command);
+    util.medicLog("    " + listCommand);
+
+    // bail out if there is more/less than one device
+    var numDevices = 0;
+    var result = shelljs.exec(listCommand, {silent: false, async: false});
+    result.output.split('\n').forEach(function (line) {
+        if (DEVICE_ROW_PATTERN.test(line)) {
+            numDevices += 1;
+        }
+    });
+    if (numDevices != 1) {
+        util.fatal("there must be exactly one emulator/device attached");
+    }
 
-    shelljs.exec(command, function (code, output) {
+    // log the output
+    util.medicLog("running:");
+    util.medicLog("    " + logCommand);
+    shelljs.exec(logCommand, {silent: false, async: false}, function (code, output) {
         if (code > 0) {
             util.fatal("Failed to run logcat command.");
         }


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