From fab0d057fc8ff7819b42b23ac3868be3ab83fceb Mon Sep 17 00:00:00 2001 From: evergreen-lee-campbell Date: Fri, 8 Jul 2016 17:01:22 +0100 Subject: [PATCH] Added 'useCRLF' option to prevent a new line feed appearing with every run on Windows --- lib/block.js | 5 ++++- lib/index.js | 3 ++- lib/parser.js | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/block.js b/lib/block.js index 636f59f..a41e9be 100644 --- a/lib/block.js +++ b/lib/block.js @@ -91,7 +91,10 @@ Block.prototype.compile = function (tasks) { } buildResult.unshift(null); - buildResult.push(null); + + if (!this.config.useCRLF) { + buildResult.push(null); + } return buildResult.join(this.linefeed); }; diff --git a/lib/index.js b/lib/index.js index 8b3892a..a037676 100644 --- a/lib/index.js +++ b/lib/index.js @@ -12,7 +12,8 @@ module.exports = function (options, userConfig) { var config = { keepUnassigned: false, keepBlockTags: false, - resolvePaths: false + resolvePaths: false, + useCRLF: false }; if (typeof userConfig === 'boolean') { diff --git a/lib/parser.js b/lib/parser.js index 98208a9..db9a298 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -23,6 +23,10 @@ function Parser(tasks, config, file) { this.tasks = tasks; this.config = config; this.file = file; + + if (this.config.useCRLF) { + regex = /(\r\n?)([ \t]*)()\n?([\s\S]*?)\n?()\n?/ig; + } } util.inherits(Parser, Transform);