Browse files

Merge pull request #244 from panopticoncentral/master

Fix package/publish problems on Windows
  • Loading branch information...
2 parents 7f6dbe9 + 8caa5dc commit b5ca54ad373396ba613d96c302ee763d531d854f @mde mde committed Feb 22, 2014
Showing with 24 additions and 3 deletions.
  1. +7 −1 lib/npm_publish_task.js
  2. +7 −0 lib/package_task.js
  3. +10 −2 lib/utils/index.js
View
8 lib/npm_publish_task.js
@@ -145,11 +145,17 @@ NpmPublishTask.prototype = new (function () {
, 'git push --tags'
];
+ var execOpts = {};
+ if (process.platform == 'win32') {
+ // Windows won't like the quotes in our cmdline
+ execOpts.windowsVerbatimArguments = true;
+ }
+
jake.exec(cmds, function () {
var version = getPackageVersionNumber();
console.log('Bumped version number to v' + version + '.');
complete();
- });
+ }, execOpts);
});
});
View
7 lib/package_task.js
@@ -233,6 +233,13 @@ PackageTask.prototype = new (function () {
var doCommand = function (p) {
var filename = path.resolve(self.packageDir + '/' + self.packageName() +
_compressOpts[p].ext);
+ if (process.platform == 'win32') {
+ // Windows full path may have drive letter, which is going to cause
+ // namespace problems, so strip it.
+ if (filename.length > 2 && filename[1] == ':') {
+ filename = filename.substr(2);
+ }
+ }
compressTaskArr.push(filename);
file(filename, [packageDirPath], function () {
View
12 lib/utils/index.js
@@ -94,6 +94,8 @@ utils.mixin(utils, new (function () {
@param {Boolean} [opts.printStderr=false] Print stderr from each command
@param {Boolean} [opts.breakOnError=true] Stop further execution on
the first error.
+ @param {Boolean} [opts.windowsVerbatimArguments=false] Don't translate
+ arguments on Windows.
@param {Function} [callback] Callback to run after executing the
commands
@@ -171,23 +173,29 @@ utils.mixin(Exec.prototype, new (function () {
// Keep running as long as there are commands in the array
if (next) {
+ var spawnOpts = {};
this.emit('cmdStart', next);
// Ganking part of Node's child_process.exec to get cmdline args parsed
if (process.platform == 'win32') {
cmd = 'cmd';
args = ['/c', next];
+ if (config.windowsVerbatimArguments) {
+ spawnOpts.windowsVerbatimArguments = true;
+ }
}
else {
cmd = '/bin/sh';
args = ['-c', next];
}
if (config.interactive) {
- sh = spawn(cmd, args, { stdio: 'inherit' });
+ spawnOpts.stdio = 'inherit';
+ sh = spawn(cmd, args, spawnOpts);
}
else {
- sh = spawn(cmd, args, { stdio: [process.stdin, 'pipe', 'pipe'] });
+ spawnOpts.stdio = [process.stdin, 'pipe', 'pipe'];
+ sh = spawn(cmd, args, spawnOpts);
// Out
sh.stdout.on('data', function (data) {
self.emit('stdout', data);

0 comments on commit b5ca54a

Please sign in to comment.