Grunt-sync
A grunt task to keep directories in sync.
It is very similar to grunt-contrib-copy but
tries to copy only those files that has actually changed.
Usage
npm install grunt-sync --save
Within your grunt file:
grunt.initConfig({
sync: {
main: {
files: [{
cwd: 'src',
src: [
'**',
'!**/*.txt'
],
dest: 'bin',
}],
pretend: true,
verbose: true
}
}
});
grunt.loadNpmTasks('grunt-sync');
grunt.registerTask('default', 'sync');
More examples
sync: {
main: {
files: [
{src: ['path/**'], dest: 'dest/'},
{cwd: 'path/', src: ['**/*.js', '**/*.css'], dest: 'dest/'},
],
verbose: true,
pretend: true,
ignoreInDest: "**/*.js",
updateAndDelete: true
}
}
Installation
npm install grunt-sync --save
Changelog
- 0.2.2 - Fixed issue with
updateAndDelete
when source patterns matches only files. - 0.2.1 - Fixed grunt Compact Format.
- 0.2.0 - Default configuration will not remove any files any more. You have to specify
updateAndDelete
option to remove any files from destination. - 0.1.2 - Deleting all files in destination on Windows solved.
- 0.1.1 - Fixed issue with trailing slash in destination.
- 0.1.0 - Files missing that are not in
src
are deleted from dest
(unless you specify updateOnly
)
Migration 0.1.x -> 0.2.x
In version 0.2 you have to explicitly specify that you want the plugin to remove files from destination. See updateAndDelete
option and run with pretend:true
first to make sure that it doesn't remove any crucial files. You can tune what files should be left untouched with ignoreInDest
property.
If you have updateOnly:true
in your 0.1 config you can remove this option. For those who used updateOnly:false
you have to include updateAndDelete:true
in 0.2 config to keep the same behavior.
TODO
- Research if it's possible to have better integration with
grunt-contrib-watch
- update only changed files instead of scanning everything. - Some tests for common problems
- Some tests to assure performance
- Rewrite
updateAndDelete
in more elegant way (maybe use patterns from source?)