Skip to content

Commit

Permalink
conversion to grunt v0.4 conventions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctalkington committed Nov 16, 2012
1 parent d0043db commit 07fecc7
Show file tree
Hide file tree
Showing 11 changed files with 204 additions and 132 deletions.
14 changes: 14 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"boss": true,
"eqnull": true,
"node": true,
"es5": true
}
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v0.4.0:
data: 2012-11-16
changes:
- Conversion to grunt v0.4 conventions.
v0.3.2:
date: 2012-10-18
changes:
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please see the [Contributing to grunt](http://gruntjs.com/contributing) guide for information on contributing to this project.
47 changes: 19 additions & 28 deletions grunt.js → Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,21 @@
*
* Copyright (c) 2012 Chris Talkington, contributors
* Licensed under the MIT license.
* https://github.com/gruntjs/grunt-contrib-copy/blob/master/LICENSE-MIT
*/

module.exports = function(grunt) {
'use strict';

// Project configuration.
grunt.initConfig({
test_vars: {
name: 'grunt-contrib-copy',
version: '0.1.0'
},

lint: {
all: ['grunt.js', 'tasks/*.js', '<config:nodeunit.tasks>']
},

jshint: {
all: [
'Gruntfile.js',
'tasks/*.js',
'<%= nodeunit.tests %>'
],
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
node: true,
es5: true
jshintrc: '.jshintrc'
}
},

Expand All @@ -43,6 +27,11 @@ module.exports = function(grunt) {
test: ['tmp']
},

test_vars: {
name: 'grunt-contrib-copy',
version: '0.1.0'
},

// Configuration to be run (and then tested).
copy: {
test: {
Expand Down Expand Up @@ -81,21 +70,23 @@ module.exports = function(grunt) {

// Unit tests.
nodeunit: {
tasks: ['test/*_test.js']
tests: ['test/*_test.js']
}
});

// Actually load this plugin's task(s).
grunt.loadTasks('tasks');

// The clean plugin helps in testing.
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-contrib-internal');

// Whenever the 'test' task is run, first clean the 'tmp' dir, then run this
// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.renameTask('test', 'nodeunit');
grunt.registerTask('test', 'clean copy nodeunit');
grunt.registerTask('test', ['clean', 'copy', 'nodeunit']);

// By default, lint and run all tests.
grunt.registerTask('default', 'lint test');
grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);
};
97 changes: 74 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,80 @@

> Copy files and folders.
### Recent Confusion
_Note that this plugin has not yet been released, and only works with the latest bleeding-edge, in-development version of grunt. See the [When will I be able to use in-development feature 'X'?](https://github.com/gruntjs/grunt/blob/devel/docs/faq.md#when-will-i-be-able-to-use-in-development-feature-x) FAQ entry for more information._

Many expect this task to work like `cp` on *nix systems but it was designed to use grunt conventions including the use of minimatch regex. We are working hard to make this and other tasks suitable for advanced users but there are no current plans to emulate `cp`.
## Getting Started
_If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide._

### Configuration
From the same directory as your project's [Gruntfile][Getting Started] and [package.json][], install this plugin with the following command:

Inside your `grunt.js` file add a section named `copy`. This section specifies the files to copy.
```bash
npm install grunt-contrib-copy --save-dev
```

#### Parameters
Once that's done, add this line to your project's Gruntfile:

##### files ```object```
```js
grunt.loadNpmTasks('grunt-contrib-copy');
```

This defines what files this task will copy and should contain key:value pairs.
If the plugin has been installed correctly, running `grunt --help` at the command line should list the newly-installed plugin's task or tasks. In addition, the plugin should be listed in package.json as a `devDependency`, which ensures that it will be installed whenever the `npm install` command is run.

The key (destination) should be an unique path (supports [grunt.template](https://github.com/gruntjs/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)).
[grunt]: http://gruntjs.com/
[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md
[package.json]: https://npmjs.org/doc/json.html

As of v0.3.0, when copying to a directory you must add a trailing slash to the destination due to added support of single file copy.

##### options ```object```
## The copy task

This controls how this task operates and should contain key:value pairs, see options below.
### Overview

#### Options
In your project's Gruntfile, add a section named `copy` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
copy: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
```

##### Recent Confusion

Many expect this task to work like `cp` on *nix systems but it was designed to use grunt conventions including the use of minimatch regex. We are working hard to make this and other tasks suitable for advanced users but there are no current plans to emulate `cp`.
### Options

##### basePath ```string```
#### files
Type: `Object`

This defines what files this task will copy and should contain key:value pairs.

The key (destination) should be an unique path (supports [grunt.template](https://github.com/gruntjs/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)).

As of v0.3.0, when copying to a directory you must add a trailing slash to the destination due to added support of single file copy.

#### options.basePath
Type: `String`

This option adjusts the folder structure when copied to the destination directory. When not explicitly set, best effort is made to locate the basePath by comparing all source filepaths left to right for a common pattern.

##### flatten ```boolean```
#### options.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 ```function```
#### options.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.

``` javascript
```js
options: {
processName: function(filename) {
if (filename == "test.jpg") {
Expand All @@ -49,21 +86,23 @@ options: {
}
```

##### processContent ```function```
#### options.processContent
Type: `Function`

This option is passed to `grunt.file.copy` as an advanced way to control the file contents that are copied.

##### processContentExclude ```string```
#### options.processContentExclude
Type: `String`

This option is passed to `grunt.file.copy` as an advanced way to control which file contents are processed.

##### minimatch ```object```
#### options.minimatch
Type: `Object`

These options will be forwarded on to expandFiles, as referenced in the [minimatch options section](https://github.com/isaacs/minimatch/#options)
### Examples

#### Config Example

``` javascript
```js
copy: {
dist: {
files: {
Expand All @@ -77,6 +116,18 @@ copy: {
}
```

## Release History

* 2012-11-16 - v0.4.0 - Conversion to grunt v0.4 conventions.
* 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 <a href="http://christalkington.com/">Chris Talkington</a>.

*Task submitted by [Chris Talkington](https://github.com/ctalkington).*
*Generated on Fri Nov 16 2012 13:43:20.*
2 changes: 2 additions & 0 deletions docs/examples.md → docs/copy-examples.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Examples

```js
copy: {
dist: {
Expand Down
32 changes: 18 additions & 14 deletions docs/options.md → docs/copy-options.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
##### files ```object```
# Options

## files
Type: `Object`

This defines what files this task will copy and should contain key:value pairs.

The key (destination) should be an unique path (supports [grunt.template](https://github.com/gruntjs/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)).

As of v0.3.0, when copying to a directory you must add a trailing slash to the destination due to added support of single file copy.

##### options ```object```

This controls how this task operates and should contain key:value pairs, see options below.

#### Options

##### basePath ```string```
## options.basePath
Type: `String`

This option adjusts the folder structure when copied to the destination directory. When not explicitly set, best effort is made to locate the basePath by comparing all source filepaths left to right for a common pattern.

##### flatten ```boolean```
## options.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 ```function```
## options.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.

``` javascript
```js
options: {
processName: function(filename) {
if (filename == "test.jpg") {
Expand All @@ -35,14 +36,17 @@ options: {
}
```

##### processContent ```function```
## options.processContent
Type: `Function`

This option is passed to `grunt.file.copy` as an advanced way to control the file contents that are copied.

##### processContentExclude ```string```
## options.processContentExclude
Type: `String`

This option is passed to `grunt.file.copy` as an advanced way to control which file contents are processed.

##### minimatch ```object```
## options.minimatch
Type: `Object`

These options will be forwarded on to expandFiles, as referenced in the [minimatch options section](https://github.com/isaacs/minimatch/#options)
20 changes: 20 additions & 0 deletions docs/copy-overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Overview

In your project's Gruntfile, add a section named `copy` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
copy: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
```

### Recent Confusion

Many expect this task to work like `cp` on *nix systems but it was designed to use grunt conventions including the use of minimatch regex. We are working hard to make this and other tasks suitable for advanced users but there are no current plans to emulate `cp`.
3 changes: 0 additions & 3 deletions docs/overview.md

This file was deleted.

11 changes: 7 additions & 4 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.3.2",
"version": "0.4.0a",
"homepage": "https://github.com/gruntjs/grunt-contrib-copy",
"author": {
"name": "Grunt Team",
Expand Down Expand Up @@ -31,10 +31,13 @@
"grunt-lib-contrib": "~0.3.0"
},
"devDependencies": {
"grunt": "~0.3.15",
"grunt-contrib-clean": "~0.3.0"
"grunt-contrib-jshint": "~0.1.0",
"grunt-contrib-nodeunit": "~0.1.0",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-internal": "*",
"grunt": "~0.4.0"
},
"keywords": [
"gruntplugin"
]
}
}
Loading

0 comments on commit 07fecc7

Please sign in to comment.