From 97025b99001b86ef4269986107c6cd649fd670f6 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 8 Dec 2015 10:23:55 +0100 Subject: [PATCH 1/3] Accept ext into transform parameters --- src/transform/index.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/transform/index.js b/src/transform/index.js index 9e92410..4bf827c 100644 --- a/src/transform/index.js +++ b/src/transform/index.js @@ -11,11 +11,10 @@ var DEFAULT_TARGET = TARGET_TYPES[0]; /** * Transform module */ -var transform = module.exports = exports = function (filepath, i, length, sourceFile, targetFile) { +var transform = module.exports = exports = function (filepath, ext, i, length, sourceFile, targetFile) { var type; if (targetFile && targetFile.path) { - var ext = extname(targetFile.path); - type = typeFromExt(ext); + type = typeFromExt(extname(targetFile.path)); } if (!isTargetType(type)) { type = DEFAULT_TARGET; @@ -36,8 +35,7 @@ transform.selfClosingTag = false; * Transform functions */ TARGET_TYPES.forEach(function (targetType) { - transform[targetType] = function (filepath) { - var ext = extname(filepath); + transform[targetType] = function (filepath, ext) { var type = typeFromExt(ext); var func = transform[targetType][type]; if (func) { From 726f5e26f3057d840d46d2c3a57b323062405a39 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 8 Dec 2015 10:27:59 +0100 Subject: [PATCH 2/3] Pass in ext based off original filename Rather than using the `getFilepath`'d filename, get the extensions of the original path, and pass it into the transform constructor. --- src/inject/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inject/index.js b/src/inject/index.js index 35ec0ea..9cbd4e1 100644 --- a/src/inject/index.js +++ b/src/inject/index.js @@ -194,7 +194,7 @@ function getNewContent (target, collection, opt) { return starttagArray .concat(files.reduce(function transformFile (lines, file, i) { var filepath = getFilepath(file, target, opt); - var transformedContents = opt.transform(filepath, file, i, files.length, target); + var transformedContents = opt.transform(filepath, extname(file.path), file, i, files.length, target); if (typeof transformedContents !== 'string') { return lines; } From d80f3c22a1cd14f0a42d7eff684cc7c6cac314c1 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 8 Dec 2015 10:28:41 +0100 Subject: [PATCH 3/3] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f9e5996..f45a0b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-inject", - "version": "3.0.0", + "version": "3.0.1", "description": "A javascript, stylesheet and webcomponent injection plugin for Gulp, i.e. inject file references into your index.html", "keywords": [ "gulpplugin",