jakejs / jake

JavaScript build tool, similar to Make or Rake. Built to work with Node.js.
http://jakejs.com
Apache License 2.0
1.97k stars 190 forks source link

Jake exec not working on Windows #314

Closed tdpsk closed 8 years ago

tdpsk commented 8 years ago

Hi,

when using jake.exec on Windows, it seems to modify the command in an incompatible way before running it. Let me make an example:

The command I am trying to run is: parse default "Deployment". If run manually from the command line, it works fine. However I have the following code in my Jakefile:

var command = 'parse default "Deployment"';
jake.logger.log(command);
jake.exec(command, { printStdout: true, breakOnError: true }, function () {
  // Save target for later use
  setTarget(target);
  complete();
});

Which outputs the command as you would expect, but then raises an error from parse because to argument seems to be translated into ["deployment"]. Here's the output for reference:

Running parse default "Deployment"
unexpected arguments, only an optional app name is expected: ["Deployment"]

Any clues where this comes from?

navneetgarg123 commented 8 years ago

Just for clarity - can you show the command line equivalent?

tdpsk commented 8 years ago

Sure, here's my output:

image

And here's the relevant part of my code:

/*
Add jake listener for global errors
*/
jake.addListener('error', function (e) {
  jake.logger.error('! An error occured: ' + e.message);
  process.exit(1);
});

/*
Tasks for interacting with the target configuration
*/
namespace('target', function () {
  desc('Switch to a different target');
  task('set', { async: true }, function (target) {
    if (!target) {
      target = process.env.target;
    }
    var deployment = verifyTarget(target);
    var command = 'parse default "${deployment}"';
    jake.logger.log('Running ${command}');

    jake.exec(command, { printStdout: true, breakOnError: true }, function () {
      // Save target for later use
      setTarget(target);
      complete();
    });
  });
});
tdpsk commented 8 years ago

Ok, solved it. jake.exec has an additional parameter "windowsVerbatimArguments" which I had to set to true. Maybe this could be added to the official docs?