Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set chmod flag by default on Windows #29

Merged
merged 4 commits into from
Dec 26, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
@@ -33,7 +33,8 @@ module.exports = function(grunt) {
"tests/src-as-array.js",
"tests/remote-host.js",
"tests/remote-dest.js",
"tests/remote-src.js"
"tests/remote-src.js",
"tests/win32-chmod.js"
],
options: {
reporter: "spec",
7 changes: 7 additions & 0 deletions lib/rsyncwrapper.js
Original file line number Diff line number Diff line change
@@ -31,6 +31,13 @@ exports.rsync = function (options,callback) {

args.push(dest);

// [rsync failed on windows, copying persmissions](https://github.com/jedrichards/rsyncwrapper/issues/28)
// [set chmod flag by default on Windows](https://github.com/jedrichards/rsyncwrapper/pull/29)
var chmodArg = _.find(options.args, function (arg) { return arg.match(/--chmod=/); });
if ( 'win32' === process.platform && !chmodArg) {
args.push("--chmod=ugo=rwX");
}

if (( typeof options.host !== "undefined" ) || ( options.ssh )) {
args.push("--rsh");
var rshCmd = "ssh";
54 changes: 54 additions & 0 deletions tests/win32-chmod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"use strict";

var fs = require("fs");
var vows = require("vows");
var assert = require("assert");
var rsync = require("../lib/rsyncwrapper").rsync;

var srcFile = "single.txt";
var srcFilePath = "[email protected]:tests/fixtures/"+srcFile;
var destDir = "./tmp/";
var copiedFile = destDir+srcFile;

exports.suite = vows.describe("Set defaul chmod for windows platform").addBatch({
"When the platform is not win32": {
topic: function() {
process.platform = 'linux';
rsync({
src: srcFilePath,
dest: destDir,
noExec: true
},this.callback);
},
"results in an rsync command that does not contains --chmod=ugo=rwX": function(error,stdout,stderr,cmd) {
assert.equal(cmd, 'rsync [email protected]:tests/fixtures/single.txt ./tmp/');
}
},
"When there is no existing chmod argument": {
topic: function() {
process.platform = 'win32';
rsync({
src: srcFilePath,
dest: destDir,
noExec: true
},this.callback);
},
"results in an rsync command that contains --chmod=ugo=rwX": function(error,stdout,stderr,cmd) {
assert.equal(cmd, 'rsync [email protected]:tests/fixtures/single.txt ./tmp/ --chmod=ugo=rwX');
}
},
"When there is and existing chmod argument": {
topic: function() {
process.platform = 'win32';
rsync({
src: srcFilePath,
dest: destDir,
noExec: true,
args: ['--chmod=u=r']
},this.callback);
},
"results in an rsync command that does not override chmod argument": function(error,stdout,stderr,cmd) {
assert.equal(cmd, 'rsync [email protected]:tests/fixtures/single.txt ./tmp/ --chmod=u=r');
}
}
});