Skip to content

Commit

Permalink
If the grunt.file.copy optional process function returns false, the f…
Browse files Browse the repository at this point in the history
…ile copy will be aborted.
  • Loading branch information
cowboy committed Apr 6, 2012
1 parent e7dfc4a commit e8bd7bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/api_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion lib/grunt/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e8bd7bf

Please sign in to comment.