grunt-sync
Advanced tools
Comparing version 0.0.7 to 0.0.8
{ | ||
"name": "grunt-sync", | ||
"description": "Task to synchronize two directories. Similar to grunt-copy but updates only files that have been changed.", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"homepage": "https://github.com/tomusdrw/grunt-sync.git", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -7,4 +7,5 @@ { | ||
"cwd": "bin/from" | ||
}] | ||
}], | ||
"verbose": true | ||
} | ||
} | ||
} |
@@ -7,7 +7,28 @@ var fs = require('promised-io/fs'); | ||
var tryCopy = function(src, dest) { | ||
try { | ||
grunt.file.copy(src, dest); | ||
} catch (e) { | ||
grunt.log.warn('Cannot copy to ' + dest.red); | ||
} | ||
}; | ||
var tryMkdir = function(dest) { | ||
try { | ||
grunt.file.mkdir(dest); | ||
} catch (e) { | ||
grunt.log.warn('Cannot create directory ' + dest.red); | ||
} | ||
}; | ||
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); | ||
try { | ||
grunt.file['delete'](dest); | ||
grunt.file.copy(src, dest); | ||
} catch(e) { | ||
grunt.log.warn('Cannot overwrite ' + dest.red); | ||
} | ||
}; | ||
var updateIfNeeded = function(options, src, dest, srcStat, destStat) { | ||
@@ -18,3 +39,3 @@ // we can now compare modification dates of files | ||
// and just update destination | ||
grunt.file.copy(src, dest); | ||
tryCopy(src, dest); | ||
} | ||
@@ -42,6 +63,6 @@ }; | ||
grunt[options.logMethod].writeln('Creating ' + dest.cyan); | ||
grunt.file.mkdir(dest); | ||
tryMkdir(dest); | ||
} else { | ||
grunt[options.logMethod].writeln('Copying ' + src.cyan + ' -> ' + dest.cyan); | ||
grunt.file.copy(src, dest); | ||
tryCopy(src, dest); | ||
} | ||
@@ -48,0 +69,0 @@ }); |
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
7334
127