Closed stevenvachon closed 7 years ago
+1
If somebody posts a pull request, I'll accept it.
There's already a grunt-spawn plugin.
grunt-spawn does not have stdio:"inherit"
. Instead, it appears to have a bunch of over-complication.
Hey @fir3pho3nixx, see above.
grunt-spawn has it's own file pattern matching code because when I started out, I quickly found that ant style wildcards and file scanning were not something that was easy to come by, rather than succumb to using regex I opted for roll-my-own. Hence all the carry on :)
If you are after the ability to make stdio: "inherit", you can do this with grunt-spawn today.
It accepts an opts parameter:
opts: { cwd: process.cwd() } -> Pass through mechanism for passing 'opts' to grunt.util.spawn. As long as the 'dontWait' flag is set to false.
This parameter is delegated down to grunt.util.spawn, which in turn would become the opts for the nodejs spawn.
*\ snippet from: http://gruntjs.com/api/grunt.util
grunt.util.spawn
Spawn a child process, keeping track of its stdout, stderr and exit code. The method returns a reference to the spawned child. When the child exits, the doneFunction is called.
grunt.util.spawn(options, doneFunction) The options object has these possible properties:
var options = { // The command to execute. It should be in the system path. cmd: commandToExecute, // If specified, the same grunt bin that is currently running will be // spawned as the child command, instead of the "cmd" option. Defaults // to false. grunt: boolean, // An array of arguments to pass to the command. args: arrayOfArguments, // Additional options for the Node.js child_process spawn method. opts: nodeSpawnOptions, // If this value is set and an error occurs, it will be used as the value // and null will be passed as the error value. fallback: fallbackValue };
* snippet end *
@stevenvachon - Comments taken on board. Will add milestone to make the code more 'obvious'. Parameters are slightly obfuscated in their current form.
Upcoming version using child_process.spawn instead of child_process.exec.
It uses
child_process.spawn()
which preserves stdout/stderr colors.If you'd rather use Node's API directly, here's how I'm currently doing it: