Permalink
Browse files

make forwarding stdio of child process optional

  • Loading branch information...
1 parent 43941de commit 3d7be783cedeed45687c57355876bf9623208c40 @dannycoates dannycoates committed Jul 21, 2010
Showing with 28 additions and 20 deletions.
  1. +27 −20 bin/inspector.js
  2. +1 −0 readme.md
View
@@ -121,6 +121,7 @@ var fileToDebug = null;
var port = 8080;
var flag = '--debug=';
var debugPort = 5858;
+var fwd = false;
process.argv.forEach(function(arg) {
if (arg.indexOf('--') > -1) {
@@ -145,13 +146,17 @@ process.argv.forEach(function(arg) {
break;
}
}
+ else if (parts[0] === '--fwd-io') {
+ fwd = true;
+ }
else if (parts[0] === '--help') {
console.log('Usage: node [node_options] debug-agent.js [options]');
console.log('Options:');
console.log('--start=[file]\t\tstarts [file] in a child process with node_g --debug');
console.log('--start-brk=[file]\tsame as start with --debug-brk');
console.log('--agent-port=[port]\tport to host the inspector (default 8080)');
console.log('--debug-port=[port]\tv8 debug port to connect to (default 5858)');
+ console.log('--fwd-io\t\t\tforward stdout and stderr from the child process to inspector console');
process.exit();
}
}
@@ -164,27 +169,29 @@ if (fileToDebug != null) {
flag = flag + debugPort;
var debugProcess = spawn('node_g', [flag, fileToDebug]);
- debugProcess.stdout.setEncoding('utf8');
- debugProcess.stdout.on('data', function(data) {
- sys.print(data);
- wsServer.broadcast(JSON.stringify({
- seq: 0,
- type: 'event',
- event: 'stdout',
- body: data
- }));
- });
+ if (fwd) {
+ debugProcess.stdout.setEncoding('utf8');
+ debugProcess.stdout.on('data', function(data) {
+ sys.print(data);
+ wsServer.broadcast(JSON.stringify({
+ seq: 0,
+ type: 'event',
+ event: 'stdout',
+ body: data
+ }));
+ });
- debugProcess.stderr.setEncoding('utf8');
- debugProcess.stderr.on('data', function(data) {
- console.error(data);
- wsServer.broadcast(JSON.stringify({
- seq: 0,
- type: 'event',
- event: 'stderr',
- body: data
- }));
- });
+ debugProcess.stderr.setEncoding('utf8');
+ debugProcess.stderr.on('data', function(data) {
+ console.error(data);
+ wsServer.broadcast(JSON.stringify({
+ seq: 0,
+ type: 'event',
+ event: 'stderr',
+ body: data
+ }));
+ });
+ }
debugProcess.on('exit', function(code) {
console.log(fileToDebug + ' exited with code ' + code);
View
@@ -49,6 +49,7 @@ external node process.
--start-brk=[file] same as start with --debug-brk
--agent-port=[port] port to host the inspector (default 8080)
--debug-port=[port] v8 debug port to connect to (default 5858)
+ --fwd-io forward stdout and stderr from the child process to inspector console
## Extensions

0 comments on commit 3d7be78

Please sign in to comment.