[debugger] print data from child process' stdout and stderr
authorFedor Indutny <fedor.indutny@gmail.com>
Sat, 10 Sep 2011 10:43:22 +0000 (17:43 +0700)
committerFedor Indutny <fedor.indutny@gmail.com>
Sat, 10 Sep 2011 10:43:22 +0000 (17:43 +0700)
lib/_debugger.js

index 90775ee..80d110c 100644 (file)
@@ -715,6 +715,14 @@ Interface.prototype.print = function(text) {
   process.stdout.write(text + '\n');
 };
 
+Interface.prototype.foreignPrint = function(text) {
+  this.print(text.toString().split(/\r\n|\r|\n/g).filter(function(chunk) {
+    return chunk;
+  }).map(function(chunk) {
+    return '< ' + chunk;
+  }).join('\n'));
+};
+
 
 Interface.prototype.handleBreak = function(r) {
   this.pause();
@@ -1095,6 +1103,8 @@ Interface.prototype.trySpawn = function(cb) {
 
   this.child = spawn(process.execPath, args, { customFds: [0, 1, 2] });
 
+  this.child.stdout.on('data', this.foreignPrint.bind(this));
+  this.child.stderr.on('data', this.foreignPrint.bind(this));
 
   this.pause();