Linked Questions

Popular Questions

NodeJS exec() command for both Windows and Ubuntu

Asked by At

Using NodeJS, NPM, and Gulp.

I want to build a gulp task to run JSDoc that works on Ubuntu and Windows.

This works on Ubuntu...

var exec = require('child_process').exec;

return function(cb) {
  exec('node node_modules/.bin/jsdoc -c jsdoc-conf.json', function(err, stdout, stderr) {
    cb(err);
  });
};

And this works on Windows...

var exec = require('child_process').exec;

return function(cb) {
  exec('node_modules\\.bin\\jsdoc -c jsdoc-conf.json', function(err, stdout, stderr) {
    cb(err);
  });
};

Needless to say, neither works on the other. How do others solve this type of problem?

Related Questions