Skip to content

Commit

Permalink
Merge pull request #23 from AlbertoGP/spawn-with-shell
Browse files Browse the repository at this point in the history
Use spawn with a shell to get best of both worlds
  • Loading branch information
jedrichards committed Mar 2, 2014
2 parents e698830 + a37efdf commit 306d6a0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/rsyncwrapper.js
@@ -1,7 +1,6 @@
"use strict";

var spawn = require("child_process").spawn;
var exec = require("child_process").exec;
var util = require("util");
var _ = require("lodash");

Expand Down Expand Up @@ -111,7 +110,16 @@ exports.rsync = function (options,callback) {

var stdout = "";
var stderr = "";
var child = exec(cmd,{maxBuffer:1000*1024},noop);
// Launch cmd in a shell just like Node's child_process.exec() does:
// see https://github.com/joyent/node/blob/937e2e351b2450cf1e9c4d8b3e1a4e2a2def58bb/lib/child_process.js#L589
var child;
if ('win32' === process.platform) {
child = spawn('cmd.exe', ['/s', '/c', '"' + cmd + '"'],
{windowsVerbatimArguments:true} );
}
else {
child = spawn('/bin/sh', ['-c', cmd]);
}

child.stdout.on("data",function (data) {
onStdout(data);
Expand Down

0 comments on commit 306d6a0

Please sign in to comment.