grunt-smart_copy v0.1.1
grunt-smart_copy
Task to synchronize two directories. Similar to grunt-copy but updates only files that have been changed. Additional option to modify file permissions, a la
chmod
.
Getting Started
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-smart_copy --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-smart_copy');
The "grunt-smart_copy" task
Overview
In your project's Gruntfile, add a section named smart_copy
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
smart_copy {
main: {
files: [{
cwd: 'src',
src: [
'**', /* Include everything */
'!**/*.txt' /* but exclude txt files */
],
dest: 'bin',
}],
writeCode: 666 // Overrite code
}
}
},
});
Options
options.mode
Type: Int
Default value: none (required)
A string value to specify the permissions' numeric mode to set on the files and/or directories, e.g.:
'755'
'644'
'400'
More examples
smart_copy: {
main: {
files: [{
src: ['path/**'], // includes files in path and its subdirs
dest: 'dest/'
},
{
cwd: 'path/', // makes all src relative to cwd
src: ['**/*.js', '**/*.css'],
dest: 'dest/'
},
]
}
}
smart_copy: {
main: {
files: [{
cwd: 'c:/source',
src: ['**', '!Bin/**', 'config ', '! * .log '],
dest: 'd:/dest'
}],
writeCode: 666 // Overrite code
}
}
Warnings
- On Windows (tested with Windows 8), the only possible values seem to be
'666'
(read/write for all users) or'444'
(read only for all users). Whatever number is set in the user column (the hundreds place value) will become the value for all columns (user, group, and other), e.g.'400'
becomes'444'
. The default permissons for both newly created files and folders is'666'
.
Task based on:
Release History
(Nothing yet)