cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cordova-coho git commit: CB-9361 Make verify-tags working nice with Windows command prompt.
Date Thu, 16 Jul 2015 04:28:16 GMT
Repository: cordova-coho
Updated Branches:
  refs/heads/master 2b863a4db -> 7c23a5ce2


CB-9361 Make verify-tags working nice with Windows command prompt.

The verify-tags command currently relies on users entering a Ctrl+D to trigger the end of
input. However, this doesn't work in the Windows command prompt.

I've modified this to use Node's readline module - read the input line by line, then process
when an empty line is encountered. This way, the tags can be pasted then simply press Enter.
Note that on Unix-like systems, Ctrl+D will still work (and if you pipe in a file that doesn't
have a blank line at the end, that will still work), since the EOF will trigger the 'close'
event.


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

Branch: refs/heads/master
Commit: 7c23a5ce273addaf985465b78e59197e7b9fafec
Parents: 2b863a4
Author: Tim Barham <tim.barham@microsoft.com>
Authored: Tue Jul 14 11:39:32 2015 +1000
Committer: Tim Barham <tim.barham@microsoft.com>
Committed: Thu Jul 16 14:24:25 2015 +1000

----------------------------------------------------------------------
 src/verify-tags.js | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/7c23a5ce/src/verify-tags.js
----------------------------------------------------------------------
diff --git a/src/verify-tags.js b/src/verify-tags.js
index 14292c6..fef27f6 100644
--- a/src/verify-tags.js
+++ b/src/verify-tags.js
@@ -25,19 +25,27 @@ var repoutil = require('./repoutil');
 var print = apputil.print;
 var chalk = require('chalk');
 var Q = require('q');
+var readline = require('readline');
 
-function readStream(stream) {
+function readInput() {
     var ret = Q.defer();
-    stream.resume();
-    stream.setEncoding('utf8');
+
+    var rl = readline.createInterface({
+        input: process.stdin
+    });
 
     var data = '';
-    stream.on('data', function(chunk) {
-        data += chunk;
+    rl.on('line', function (line) {
+        if (line) {
+            data += line + '\n';
+        } else {
+            rl.close();
+        }
     });
-    stream.on('end', function() {
+    rl.on('close', function () {
         ret.resolve(data);
     });
+
     return ret.promise;
 }
 
@@ -56,10 +64,10 @@ exports.createCommand = function*(argv) {
         process.exit(1);
     }
     if (process.stdin.isTTY) {
-        console.log('Paste in print-tags output then hit Ctrl-D');
+        console.log('Paste in print-tags output then hit Enter');
     }
 
-    var input = yield readStream(process.stdin);
+    var input = yield readInput();
     var pattern = /\s*(cordova-.+?):\s*(.*?)\s+\((.*?)\)/g;
     var m;
     var results = [];


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


Mime
View raw message