Skip to content

Commit

Permalink
Also pass destpath into file.copy "process" function. Closes gruntjsg…
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboy committed Jun 19, 2014
1 parent b50541b commit 2f0053f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/grunt/file.js
Expand Up @@ -336,7 +336,7 @@ file._copy = function(srcpath, destpath, options) {
if (process) {
grunt.verbose.write('Processing source...');
try {
contents = options.process(contents, srcpath);
contents = options.process(contents, srcpath, destpath);
grunt.verbose.ok();
} catch(e) {
grunt.verbose.error();
Expand Down
7 changes: 4 additions & 3 deletions test/grunt/file_test.js
Expand Up @@ -513,12 +513,13 @@ exports['file'] = {
test.done();
},
'copy and process': function(test) {
test.expect(13);
test.expect(14);
var tmpfile;
tmpfile = new Tempfile();
grunt.file.copy('test/fixtures/utf8.txt', tmpfile.path, {
process: function(src, filepath) {
test.equal(filepath, 'test/fixtures/utf8.txt', 'filepath should be passed in, as-specified.');
process: function(src, srcpath, destpath) {
test.equal(srcpath, 'test/fixtures/utf8.txt', 'srcpath should be passed in, as-specified.');
test.equal(destpath, tmpfile.path, 'destpath should be passed in, as-specified.');
test.equal(Buffer.isBuffer(src), false, 'when no encoding is specified, use default encoding and process src as a string');
test.equal(typeof src, 'string', 'when no encoding is specified, use default encoding and process src as a string');
return 'føø' + src + 'bår';
Expand Down

0 comments on commit 2f0053f

Please sign in to comment.