From 2f0053f0db154f0911ff6498b4223d64dee3f76e Mon Sep 17 00:00:00 2001 From: Ben Alman Date: Thu, 19 Jun 2014 12:05:10 -0400 Subject: [PATCH] Also pass destpath into file.copy "process" function. Closes gh-1161. --- lib/grunt/file.js | 2 +- test/grunt/file_test.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/grunt/file.js b/lib/grunt/file.js index 46b9f4a20..c9a7eaeb6 100644 --- a/lib/grunt/file.js +++ b/lib/grunt/file.js @@ -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(); diff --git a/test/grunt/file_test.js b/test/grunt/file_test.js index 21342697f..613ddc330 100644 --- a/test/grunt/file_test.js +++ b/test/grunt/file_test.js @@ -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';