grunt-sync
Advanced tools
Comparing version 0.0.6 to 0.0.7
{ | ||
"name": "grunt-sync", | ||
"description": "Task to synchronize two directories. Similar to grunt-copy but updates only files that have been changed.", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"homepage": "https://github.com/tomusdrw/grunt-sync.git", | ||
@@ -39,5 +39,5 @@ "author": { | ||
"grunt": "0.4.x", | ||
"grunt-complexity": "git+ssh://git@github.com:tomusdrw/grunt-complexity.git", | ||
"grunt-simple-mocha": "0.3.x", | ||
"grunt-contrib-jshint": "0.1.x" | ||
"grunt-contrib-jshint": "0.1.x", | ||
"grunt-complexity": "^0.1.51" | ||
}, | ||
@@ -44,0 +44,0 @@ "keywords": [ |
@@ -21,6 +21,10 @@ # Grunt-sync | ||
files: [{ | ||
cwd: 'src' | ||
src: '**', | ||
cwd: 'src', | ||
src: [ | ||
'**', /* Include everything */ | ||
'!**/*.txt' /* but exclude txt files */ | ||
], | ||
dest: 'bin', | ||
}] | ||
}], | ||
verbose: true // Display log messages when copying files | ||
} | ||
@@ -42,3 +46,4 @@ } | ||
{cwd: 'path/', src: ['**/*.js', '**/*.css'], dest: 'dest/'}, // makes all src relative to cwd | ||
] | ||
], | ||
verbose: true | ||
} | ||
@@ -45,0 +50,0 @@ } |
@@ -7,11 +7,11 @@ var fs = require('promised-io/fs'); | ||
var overwriteDest = function(src, dest) { | ||
grunt.verbose.writeln('Overwriting ' + dest.cyan + 'because type differs.'); | ||
var overwriteDest = function(options, src, dest) { | ||
grunt[options.logMethod].writeln('Overwriting ' + dest.cyan + 'because type differs.'); | ||
grunt.file['delete'](dest); | ||
grunt.file.copy(src, dest); | ||
}; | ||
var updateIfNeeded = function(src, dest, srcStat, destStat) { | ||
var updateIfNeeded = function(options, src, dest, srcStat, destStat) { | ||
// we can now compare modification dates of files | ||
if(srcStat.mtime.getTime() > destStat.mtime.getTime()) { | ||
grunt.verbose.writeln('Updating file ' + dest.cyan); | ||
grunt[options.logMethod].writeln('Updating file ' + dest.cyan); | ||
// and just update destination | ||
@@ -22,3 +22,3 @@ grunt.file.copy(src, dest); | ||
var processPair = function(src, dest) { | ||
var processPair = function(options, src, dest) { | ||
//stat destination file | ||
@@ -33,5 +33,5 @@ return promise.all([fs.stat(src), fs.stat(dest)]).then(function(result) { | ||
if(typeDiffers) { | ||
overwriteDest(src, dest); | ||
overwriteDest(options,src, dest); | ||
} else if(!isSrcDirectory) { | ||
updateIfNeeded(src, dest, srcStat, destStat); | ||
updateIfNeeded(options, src, dest, srcStat, destStat); | ||
} | ||
@@ -42,6 +42,6 @@ }, function() { | ||
if(grunt.file.isDir(src)) { | ||
grunt.verbose.writeln('Creating ' + dest.cyan); | ||
grunt[options.logMethod].writeln('Creating ' + dest.cyan); | ||
grunt.file.mkdir(dest); | ||
} else { | ||
grunt.verbose.writeln('Copying ' + src.cyan + ' -> ' + dest.cyan); | ||
grunt[options.logMethod].writeln('Copying ' + src.cyan + ' -> ' + dest.cyan); | ||
grunt.file.copy(src, dest); | ||
@@ -54,2 +54,5 @@ } | ||
var done = this.async(); | ||
var options = { | ||
logMethod: this.data.verbose ? 'log' : 'verbose' | ||
}; | ||
@@ -65,3 +68,3 @@ promise.all(this.files.map(function(fileDef) { | ||
} | ||
return processPair(path.join(cwd, src), dest); | ||
return processPair(options, path.join(cwd, src), dest); | ||
})); | ||
@@ -68,0 +71,0 @@ })).then(function(promises) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6883
8
107
54