gruntjs/grunt — pull request #699 by jharding (2013-03-01 18:11:15+00:00)
Title: Improve usability of child process's stream interface for util.spawn

Right now, if the command passed to `util.spawn` isn't found, `undefined` is returned and the `done` callback is invoked. This makes it impossible to rely entirely on the stream interface of the spawned child process. For example, I couldn't do the following:

```javascript
var child = grunt.spawn('notacommand');

child.stdout.on('data', function(d) { grunt.log.write(d); });
child.stderr.on('data', function(d) { grunt.log.error(d); });
```

Instead, I'd have to do something like:

```javascript
var child = grunt.spawn('notacommand', function(error, result, code) {
code !== 0 && grunt.log.error(result.stderr);
});

child && child.stdout.on('data', function(d) { grunt.log.write(d); });
child && child.stderr.on('data', function(d) { grunt.log.error(d); });
```

This pull request adds support for the former example. The downside to this change is that the error message for when a command is not found is not as descriptive as it previously was. If this is a sticking point for this pull request, I'll address the regression.

One other note – I didn't test this out on Windows.