Permalink
Browse files

Use close event for child processes in grunt.utils.spawn. Closes gh-322

…, gh-323.
  • Loading branch information...
1 parent 882e5d1 commit 638cf96ab48bd6c789c5d91c5e961fd063fef5c4 @scottgonzalez scottgonzalez committed with Jul 30, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/grunt/utils.js
View
@@ -92,7 +92,10 @@ utils.spawn = function(opts, done) {
var stderr = '';
child.stdout.on('data', function(buf) { stdout += buf; });
child.stderr.on('data', function(buf) { stderr += buf; });
- child.on('exit', function(code) {
+ // Node 0.8 no longer waits for stdio pipes to be closed before emitting the
+ // exit event (grunt issue #322).
+ var eventName = process.version.split('.')[1] === '6' ? 'exit' : 'close';
+ child.on(eventName, function(code) {
// Remove trailing whitespace (newline)
stdout = _.rtrim(stdout);
stderr = _.rtrim(stderr);

0 comments on commit 638cf96

Please sign in to comment.