gruntjs/grunt-contrib-copy — pull request #56 by dancingplatypus (2013-02-27 23:26:52+00:00)
Title: Added 'onlyIf' option (conditional copying), as well as a few other modifications.

I know that this is an unsolicited pull request, but please review and see if this is something you'd like to include. The changes include:

* The time stamp of the source file is transferred to the destination. This allows us an accurate way to determine whether or not a file being copied is newer or different than the one at the destination.
* Addition of a new option, 'onlyIf', which allows for us to specify under what conditions a file should be copied. I added this feature specifically because of indexing features in programs such as WebStorm, which might pause for long periods of time after a build as it rescans all of the files, when it should only be scanning a subset. It also allows builds to go much more quickly if there are significant assets to copy over. Ann excerpt from the modified README.md follows:

----
#### onlyIf
Type: `String` | `Function` Default 'always'

Controls whether or not the file will be copied.

If `onlyIf` is a function, is should have the signature: `fn(srcPath, destPath, srcStat, destStat)`
and it should return `true` if the file is to be copied, `false` otherwise.

If `onlyIf` is a string, then it must be one of:
* **always** -- the source will always be copied to the destination
* **newer** -- the source will only be copied if it is newer than the destination
* **modified** -- the source will be copied only if its timestamp is different than that of the destination
* **missing** -- the source will only be copied if there is no destination file
----

* I have modified the task to work asynchronously. This is mostly about peace of mind so that I'm not invoking a lot of synchronized nodejs functions. However, I am not pluging into the timeout function to cancel the operation -- mainly because I've no idea how long this process might take given a large number of files. The downside is that async is now a dependency.
* I have included nodeunit test cases for the new functionality.

I am using this version in house, but frankly, I'd rather be contributing to the community than maintaining my own divergence. If you have suggestions or questions, please write.

Thank you.