From 3aa9d489341ace20c278e69a8cad55f6e0fc242f Mon Sep 17 00:00:00 2001 From: ekino-dgp Date: Mon, 21 Mar 2016 16:26:34 +0100 Subject: [PATCH] expose srcDirname to process option so that we can genereate a relative output path Update README.md --- README.md | 2 +- tasks/filerev.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8c793dd..2595da3 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Default: `8` The number of characters of the file hash to prefix the file name with. -#### options.process(basename, name, extension) +#### options.process(basename, name, extension, srcDirname) Type: `function` Default: `null` diff --git a/tasks/filerev.js b/tasks/filerev.js index 28e570a..7ef9ee4 100644 --- a/tasks/filerev.js +++ b/tasks/filerev.js @@ -29,7 +29,7 @@ module.exports = function (grunt) { var stat = fs.lstatSync(el.dest); if (stat && !stat.isDirectory()) { - grunt.fail.fatal('Destination ' + el.dest + ' for target ' + target + ' is not a directory'); + grunt.fail.fatal('Destination ' + el.dest + ' for target ' + target + ' is not a directory'); } } catch (err) { grunt.verbose.writeln('Destination dir ' + el.dest + ' does not exists for target ' + target + ': creating'); @@ -51,7 +51,7 @@ module.exports = function (grunt) { var newName; if (typeof options.process === 'function') { - newName = options.process(path.basename(file, ext), suffix, ext.slice(1)); + newName = options.process(path.basename(file, ext), suffix, ext.slice(1), path.dirname(file)); } else { if (options.process) { grunt.log.error('options.process must be a function; ignoring');