grunt-rsync
Version:
A Grunt task for accessing the file copying and syncing capabilities of the rsync command line utility. Uses the rsyncwrapper npm module for the core functionality.
39 lines (30 loc) • 1.04 kB
JavaScript
;
var rsync = require("rsyncwrapper");
module.exports = function (grunt) {
grunt.task.registerMultiTask("rsync","Performs rsync tasks.",function () {
var done = this.async();
var options = this.options();
grunt.log.writelns("rsyncing "+options.src+" >>> "+options.dest);
if ( !options.onStdout ) {
options.onStdout = function (data) {
grunt.log.write(data.toString("utf8"));
};
}
try {
rsync(options,function (error,stdout,stderr,cmd) {
grunt.log.writeln("Shell command was: "+cmd);
if ( error ) {
grunt.log.error();
grunt.log.writeln(error.toString().red);
done(false);
} else {
grunt.log.ok();
done(true);
}
});
} catch (error) {
grunt.log.writeln("\n"+error.toString().red);
done(false);
}
});
};