Skip to content

Commit

Permalink
updating to work with grunt v0.4.0rc5.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctalkington committed Jan 16, 2013
1 parent 2bd6f0e commit bffcef8
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 244 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
v0.4.0:
data: 2012-12-xx
v0.4.0rc5:
date: 2013-01-14
changes:
- Updating to work with grunt v0.4.0rc5.
- Conversion to grunt v0.4 conventions.
- Replace basePath with cwd.
- Empty directory support.
Expand Down
41 changes: 11 additions & 30 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,23 @@ module.exports = function(grunt) {
// Configuration to be run (and then tested).
copy: {
main: {
options: {
cwd: 'test/fixtures'
},
files: {
'tmp/copy_test_files/': ['*.*'],
'tmp/copy_test_mix/': ['**'],
'tmp/copy_test_v<%= test_vars.version %>/': ['<%= test_vars.match %>']
}
files: [
{expand: true, cwd: 'test/fixtures', src: ['*.*'], dest: 'tmp/copy_test_files/'},
{expand: true, cwd: 'test/fixtures', src: ['**'], dest: 'tmp/copy_test_mix/'},
{expand: true, cwd: 'test/fixtures', src: ['<%= test_vars.match %>'], dest: 'tmp/copy_test_v<%= test_vars.version %>/'}
]
},

flatten: {
options: {
flatten: true
},
files: {
'tmp/copy_test_flatten/': ['test/fixtures/**']
}
},

minimatch: {
options: {
cwd: 'test/fixtures',
excludeEmpty: true,
minimatch: {
dot: true
}
},
files: {
'tmp/copy_minimatch/': ['*']
}
files: [
{expand: true, flatten: true, filter: 'isFile', src: ['test/fixtures/**'], dest: 'tmp/copy_test_flatten/'}
]
},

single: {
files: {
'tmp/single.js': ['test/fixtures/test.js']
}
files: [
{src: ['test/fixtures/test.js'], dest: 'tmp/single.js'}
]
}
},

Expand Down
74 changes: 11 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,55 +21,9 @@ _This task is a [multi task][] so any targets, files and options should be speci
[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.
_Version `0.4.x` of this plugin is compatible with Grunt `0.4.x`. Version `0.3.x` of this plugin is compatible with Grunt `0.3.x`._

#### 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;
}
}
```
### Options

#### processContent
Type: `Function`
Expand All @@ -81,31 +35,25 @@ 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"
}
main: {
files: [
{src: ['path/*'], dest: 'dest/', filter: 'isFile'}, // includes files in path
{src: ['path/**'], dest: 'dest/'}, // includes files in path and its subdirs
{expand: true, cwd: 'path/', src: ['**'], dest: 'dest/'}, // makes all src relative to cwd
{expand: true, flatten: true, src: ['path/**'], dest: 'dest/', filter: 'isFile'} // flattens results to a single level
]
}
}
```


## Release History

* 2012-11-29   v0.4.0   Conversion to grunt v0.4 conventions. Replace basePath with cwd. Empty directory support.
* 2013-01-13   v0.4.0rc5   Updating to work with grunt v0.4.0rc5. 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.
Expand All @@ -118,4 +66,4 @@ copy: {

Task submitted by [Chris Talkington](http://christalkington.com/)

*This file was generated on Thu Nov 29 2012 20:23:02.*
*This file was generated on Wed Jan 16 2013 00:16:55.*
15 changes: 7 additions & 8 deletions docs/copy-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

```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"
}
main: {
files: [
{src: ['path/*'], dest: 'dest/', filter: 'isFile'}, // includes files in path
{src: ['path/**'], dest: 'dest/'}, // includes files in path and its subdirs
{expand: true, cwd: 'path/', src: ['**'], dest: 'dest/'}, // makes all src relative to cwd
{expand: true, flatten: true, src: ['path/**'], dest: 'dest/', filter: 'isFile'} // flattens results to a single level
]
}
}
```
53 changes: 0 additions & 53 deletions docs/copy-options.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,5 @@
# 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`

Expand All @@ -57,8 +9,3 @@ This option is passed to `grunt.file.copy` as an advanced way to control the fil
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)
2 changes: 2 additions & 0 deletions docs/copy-overview.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{%= s.multi_task %}

_Version `0.4.x` of this plugin is compatible with Grunt `0.4.x`. Version `0.3.x` of this plugin is compatible with Grunt `0.3.x`._
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grunt-contrib-copy",
"description": "Copy files and folders.",
"version": "0.4.0a",
"version": "0.4.0rc5",
"homepage": "https://github.com/gruntjs/grunt-contrib-copy",
"author": {
"name": "Grunt Team",
Expand Down Expand Up @@ -31,11 +31,11 @@
"grunt-lib-contrib": "~0.4.0"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.1.0",
"grunt-contrib-nodeunit": "~0.1.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-jshint": "~0.1.1rc5",
"grunt-contrib-nodeunit": "~0.1.2rc5",
"grunt-contrib-clean": "~0.4.0rc5",
"grunt-contrib-internal": "~0.1.1",
"grunt": "~0.4.0"
"grunt": "~0.4.0rc5"
},
"keywords": [
"gruntplugin"
Expand Down
Loading

0 comments on commit bffcef8

Please sign in to comment.