node-triton#52 Fix 'triton ssh ...' stdout/stderr to fully flush with node >= 4.x

Fixes #52
This commit is contained in:
Trent Mick 2016-02-26 15:28:21 -08:00
parent 31ef581980
commit a1df6e0fe7
2 changed files with 13 additions and 2 deletions

View File

@ -2,7 +2,7 @@
## 4.5.3 (not yet released) ## 4.5.3 (not yet released)
(nothing yet) - #52 Fix 'triton ssh ...' stdout/stderr to fully flush with node >= 4.x.
## 4.5.2 ## 4.5.2

View File

@ -50,8 +50,19 @@ function do_ssh(subcmd, opts, args, callback) {
args = ['-l', user].concat(ip).concat(args); args = ['-l', user].concat(ip).concat(args);
self.top.log.info({args: args}, 'forking ssh'); self.top.log.info({args: args}, 'forking ssh');
var child = spawn('ssh', args, {stdio: 'inherit'}); var child = spawn('ssh', args);
child.stdout.on('data', function (chunk){
process.stdout.write(chunk);
});
child.stderr.on('data', function (chunk){
process.stderr.write(chunk);
});
child.on('close', function (code) { child.on('close', function (code) {
/*
* Once node 0.10 support is dropped we could instead:
* process.exitCode = code;
* callback();
*/
process.exit(code); process.exit(code);
}); });
}); });