diff --git a/docs/api_file.md b/docs/api_file.md index e9b448e3c..e5d565af3 100644 --- a/docs/api_file.md +++ b/docs/api_file.md @@ -49,7 +49,7 @@ The `options` object has these possible properties: var options = { // If specified, the file contents will be parsed as `utf8` and passed into // the function, whose return value will be used as the destination file's - // contents. + // contents. If this function returns false, the file copy will be aborted. process: processFunction, // These optional wildcard patterns will be matched against the filepath using // grunt.file.isMatch. If a specified wildcard pattern matches, the file will diff --git a/lib/grunt/file.js b/lib/grunt/file.js index f1fae4193..f98ef8c4b 100644 --- a/lib/grunt/file.js +++ b/lib/grunt/file.js @@ -201,7 +201,12 @@ file.copy = function(srcpath, destpath, options) { throw grunt.task.taskError('Error while processing "' + srcpath + '" file.', e); } } - file.write(destpath, src); + // Abort copy if the process function returns false. + if (src === false) { + grunt.verbose.writeln('Write aborted.'); + } else { + file.write(destpath, src); + } }; // Read a file, parse its contents, return an object.