-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for copying empty directories.
this has been another big user request that should fit nicely along side the new cwd option.
- Loading branch information
1 parent
66f6fc2
commit 3a3c591
Showing
14 changed files
with
173 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,121 @@ | ||
# grunt-contrib-copy [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-contrib-copy.png?branch=master)](http://travis-ci.org/gruntjs/grunt-contrib-copy) | ||
|
||
> Copy files and folders. | ||
|
||
## Getting Started | ||
If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide, as it explains how to create a [gruntfile][Getting Started] as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command: | ||
|
||
```shell | ||
npm install grunt-contrib-copy --save-dev | ||
``` | ||
|
||
[grunt]: http://gruntjs.com/ | ||
[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md | ||
|
||
|
||
## Copy task | ||
_Run this task with the `grunt copy` command._ | ||
|
||
_This task is a [multi task][] so any targets, files and options should be specified according to the [multi task][] documentation._ | ||
[multi task]: https://github.com/gruntjs/grunt/wiki/Configuring-tasks | ||
|
||
|
||
### Options | ||
|
||
#### cwd | ||
Type: `String` | ||
|
||
This option sets the current working directory for use with the minimatch and copy process. This helps translate paths when copied so that the destination stucture matches the source structure exactly. Without a `cwd` set, all paths are relative to the gruntfile directory which can cause extra depth to be added to your copied structure when it may not be desired. | ||
|
||
When copying to a directory you must add a trailing slash to the destination due to added support of single file copy. | ||
|
||
```js | ||
copy: { | ||
target: { | ||
options: { | ||
cwd: 'path/to/sources' | ||
}, | ||
files: { | ||
'tmp/test/': ['*', 'sub1/*'] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
#### flatten | ||
Type: `Boolean` | ||
Default: false | ||
|
||
This option performs a flat copy that dumps all the files into the root of the destination directory, overwriting files if they exist. | ||
|
||
#### processName | ||
Type: `Function` | ||
|
||
This option accepts a function that adjusts the filename of the copied file. Function is passed filename and should return a string. | ||
|
||
```js | ||
options: { | ||
processName: function(filename) { | ||
if (filename == "test.jpg") { | ||
filename = "newname.jpg"; | ||
} | ||
return filename; | ||
} | ||
} | ||
``` | ||
|
||
#### processContent | ||
Type: `Function` | ||
|
||
This option is passed to `grunt.file.copy` as an advanced way to control the file contents that are copied. | ||
|
||
#### processContentExclude | ||
Type: `String` | ||
|
||
This option is passed to `grunt.file.copy` as an advanced way to control which file contents are processed. | ||
|
||
#### minimatch | ||
Type: `Object` | ||
|
||
These options will be forwarded on to expandFiles, as referenced in the [minimatch options section](https://github.com/isaacs/minimatch/#options) | ||
|
||
### Usage Examples | ||
|
||
```js | ||
copy: { | ||
dist: { | ||
files: { | ||
"path/to/directory/": "path/to/source/*", // includes files in dir | ||
"path/to/directory/": "path/to/source/**", // includes files in dir and subdirs | ||
"path/to/project-<%= pkg.version %>/": "path/to/source/**", // variables in destination | ||
"path/to/directory/": ["path/to/sources/*.js", "path/to/more/*.js"], // include JS files in two diff dirs | ||
"path/to/filename.ext": "path/to/source.ext" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
|
||
## Release History | ||
|
||
* 2012-11-28 v0.4.0 Conversion to grunt v0.4 conventions. Replace basePath with cwd | ||
* 2012-10-17 v0.3.2 Pass copyOptions on single file copy | ||
* 2012-10-11 v0.3.1 Rename grunt-contrib-lib dep to grunt-lib-contrib. | ||
* 2012-09-23 v0.3.0 General cleanup and consolidation. Global options depreciated. | ||
* 2012-09-17 v0.2.4 No valid source check. | ||
* 2012-09-16 v0.2.3 Path.sep fallback for node <= 0.7.9. | ||
* 2012-09-16 v0.2.2 Single file copy support. Test refactoring. | ||
* 2012-09-06 v0.2.0 Refactored from grunt-contrib into individual repo. | ||
|
||
--- | ||
|
||
Task submitted by [Chris Talkington](http://christalkington.com/) | ||
|
||
*This file was generated on Wed Nov 28 2012 08:36:21.* | ||
# grunt-contrib-copy [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-contrib-copy.png?branch=master)](http://travis-ci.org/gruntjs/grunt-contrib-copy) | ||
|
||
> Copy files and folders. | ||
|
||
## Getting Started | ||
If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide, as it explains how to create a [gruntfile][Getting Started] as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command: | ||
|
||
```shell | ||
npm install grunt-contrib-copy --save-dev | ||
``` | ||
|
||
[grunt]: http://gruntjs.com/ | ||
[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md | ||
|
||
|
||
## Copy task | ||
_Run this task with the `grunt copy` command._ | ||
|
||
_This task is a [multi task][] so any targets, files and options should be specified according to the [multi task][] documentation._ | ||
[multi task]: https://github.com/gruntjs/grunt/wiki/Configuring-tasks | ||
|
||
|
||
### Options | ||
|
||
#### cwd | ||
Type: `String` | ||
|
||
This option sets the current working directory for use with the minimatch and copy process. This helps translate paths when copied so that the destination stucture matches the source structure exactly. Without a `cwd` set, all paths are relative to the gruntfile directory which can cause extra depth to be added to your copied structure when it may not be desired. | ||
|
||
When copying to a directory you must add a trailing slash to the destination due to added support of single file copy. | ||
|
||
```js | ||
copy: { | ||
target: { | ||
options: { | ||
cwd: 'path/to/sources' | ||
}, | ||
files: { | ||
'tmp/test/': ['*', 'sub1/*'] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
#### excludeEmpty | ||
Type: `Boolean` | ||
Default: false | ||
|
||
This option excludes empty folders from being copied to the destination directory. | ||
|
||
#### flatten | ||
Type: `Boolean` | ||
Default: false | ||
|
||
This option performs a flat copy that dumps all the files into the root of the destination directory, overwriting files if they exist. | ||
|
||
#### processName | ||
Type: `Function` | ||
|
||
This option accepts a function that adjusts the filename of the copied file. Function is passed filename and should return a string. | ||
|
||
```js | ||
options: { | ||
processName: function(filename) { | ||
if (filename == "test.jpg") { | ||
filename = "newname.jpg"; | ||
} | ||
return filename; | ||
} | ||
} | ||
``` | ||
|
||
#### processContent | ||
Type: `Function` | ||
|
||
This option is passed to `grunt.file.copy` as an advanced way to control the file contents that are copied. | ||
|
||
#### processContentExclude | ||
Type: `String` | ||
|
||
This option is passed to `grunt.file.copy` as an advanced way to control which file contents are processed. | ||
|
||
#### minimatch | ||
Type: `Object` | ||
|
||
These options will be forwarded on to expandFiles, as referenced in the [minimatch options section](https://github.com/isaacs/minimatch/#options) | ||
|
||
### Usage Examples | ||
|
||
```js | ||
copy: { | ||
dist: { | ||
files: { | ||
"path/to/directory/": "path/to/source/*", // includes files in dir | ||
"path/to/directory/": "path/to/source/**", // includes files in dir and subdirs | ||
"path/to/project-<%= pkg.version %>/": "path/to/source/**", // variables in destination | ||
"path/to/directory/": ["path/to/sources/*.js", "path/to/more/*.js"], // include JS files in two diff dirs | ||
"path/to/filename.ext": "path/to/source.ext" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
|
||
## Release History | ||
|
||
* 2012-11-29 v0.4.0 Conversion to grunt v0.4 conventions. Replace basePath with cwd. Empty directory support. | ||
* 2012-10-17 v0.3.2 Pass copyOptions on single file copy. | ||
* 2012-10-11 v0.3.1 Rename grunt-contrib-lib dep to grunt-lib-contrib. | ||
* 2012-09-23 v0.3.0 General cleanup and consolidation. Global options depreciated. | ||
* 2012-09-17 v0.2.4 No valid source check. | ||
* 2012-09-16 v0.2.3 Path.sep fallback for node <= 0.7.9. | ||
* 2012-09-16 v0.2.2 Single file copy support. Test refactoring. | ||
* 2012-09-06 v0.2.0 Refactored from grunt-contrib into individual repo. | ||
|
||
--- | ||
|
||
Task submitted by [Chris Talkington](http://christalkington.com/) | ||
|
||
*This file was generated on Thu Nov 29 2012 20:23:02.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('hello'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('hello'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('hello'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$(document).ready(function(){$.noConflict();}); |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('hello'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('hello'); |