From 3ae85df804b9429fea08890b29b6a9b7edfc17fe Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 12 Feb 2015 22:22:08 -0800 Subject: [PATCH 1/2] Update to resolve relative file path based on curDir When getting relative path for '/module/img/sample-img.png' ``` path.relative( srcDir, srcFile ) ``` returns 'sample-img.png' ``` path.relative(curDir, srcFile) ``` returns 'img/sample-img.png' This change allows for cartero-node-hook to return a path with just the module directory updated to the fingerprint. --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index d11ab0e..964dd90 100644 --- a/index.js +++ b/index.js @@ -11,10 +11,10 @@ module.exports = function( srcFile, directoryMap ) { var dstDir = typeof directoryMap === 'function' ? directoryMap( curDir ) : directoryMap[ curDir ]; if( dstDir ) { - dstFile = path.resolve( dstDir, path.relative( srcDir, srcFile ) ); + dstFile = path.resolve( dstDir, path.relative( curDir, srcFile ) ); break; } } - + return dstFile ? dstFile : srcFile; -}; \ No newline at end of file +}; From ba6d552a29ec9d79655bea486c5beeb0f10a9833 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 12 Feb 2015 22:28:29 -0800 Subject: [PATCH 2/2] Removing srcDir since it is not needed anymore. --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index 964dd90..85d75f4 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,6 @@ module.exports = function( srcFile, directoryMap ) { var dstFile; var curDir = srcFile; - var srcDir = path.dirname( srcFile ); while( curDir !== '' && curDir !== path.sep ) { curDir = path.dirname( curDir );