Fix NodeJS Spawing@Windows

mardi 13 janvier 2015
Currently I'm developing a small Mobile PoC based on a Hybrid mobile framework. The app automation relies on the famous task runner tool: Grunt. When the task runner needs to run a system command it uses the spawn API.

var spawn = require('child_process').spawn;
This works fine on any *nix platforms but not with Windows... (once again).
Hopefully, a node package exists to solve that: win-spawn.
So now this is how I require the spawn API

var spawn = (process.platform === 'win32') ? require('win-spawn') : require('child_process').spawn;