From 9858f19ff4f412ca8ebcbbfa4890cbd1cefd8650 Mon Sep 17 00:00:00 2001 From: Russell Sinclair Date: Tue, 20 Aug 2019 09:46:06 -0400 Subject: [PATCH 1/3] Add option to set your own output extension Fixes #48 --- src/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 4a82bfa..c0a3f41 100644 --- a/src/index.js +++ b/src/index.js @@ -29,6 +29,10 @@ module.exports = function mjml(mjmlEngine, options) { const raise = error(localOptions.filePath); + if (localOptions.fileExt === undefined) { + localOptions.fileExt = ".html"; + } + if (file.isStream()) { this.emit("error", raise("Streams are not supported!")); return callback(); @@ -47,7 +51,7 @@ module.exports = function mjml(mjmlEngine, options) { // [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues output.contents = Buffer.from(render.html); - output.path = replaceExt(file.path.toString(), ".html"); + output.path = replaceExt(file.path.toString(), localOptions.fileExt); this.push(output); } return callback(); From db7f3c024d626927e01acb093aa5377e80dd2543 Mon Sep 17 00:00:00 2001 From: Russell Sinclair Date: Tue, 20 Aug 2019 10:01:55 -0400 Subject: [PATCH 2/3] Document fileExt option --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index ce4e4ad..725be9b 100644 --- a/README.md +++ b/README.md @@ -55,3 +55,18 @@ gulp.task('default', function () { .pipe(gulp.dest('./html')) }) ``` + +> If you want to override the default file extension that is output use `fileExt` + +```javascript +const gulp = require('gulp') +const mjml = require('gulp-mjml') + +const mjmlEngine = require('mjml') + +gulp.task('default', function () { + return gulp.src('./test.mjml') + .pipe(mjml(mjmlEngine, {minify: true, fileExt: ".txt"})) + .pipe(gulp.dest('./html')) +}) +``` \ No newline at end of file From fbd0d37a4d13ad54e53a90e259c03b9a4fae7332 Mon Sep 17 00:00:00 2001 From: Russell Sinclair Date: Tue, 20 Aug 2019 12:03:42 -0400 Subject: [PATCH 3/3] Per comment --- src/index.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index c0a3f41..c1671e1 100644 --- a/src/index.js +++ b/src/index.js @@ -29,10 +29,6 @@ module.exports = function mjml(mjmlEngine, options) { const raise = error(localOptions.filePath); - if (localOptions.fileExt === undefined) { - localOptions.fileExt = ".html"; - } - if (file.isStream()) { this.emit("error", raise("Streams are not supported!")); return callback(); @@ -51,7 +47,7 @@ module.exports = function mjml(mjmlEngine, options) { // [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues output.contents = Buffer.from(render.html); - output.path = replaceExt(file.path.toString(), localOptions.fileExt); + output.path = replaceExt(file.path.toString(), localOptions.fileExt || ".html"); this.push(output); } return callback();