From a561b88d22f9316462f71a45a4910d41fa574cf5 Mon Sep 17 00:00:00 2001 From: Ilya Fadeev Date: Sun, 11 Jun 2017 23:33:45 -0400 Subject: [PATCH] Allow extra space before steal-remove-start and -end tags to support standard linting. #727 --- lib/build/clean.js | 2 +- lib/build/clean_test.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 lib/build/clean_test.js diff --git a/lib/build/clean.js b/lib/build/clean.js index 2f31842d..fa3ea9df 100644 --- a/lib/build/clean.js +++ b/lib/build/clean.js @@ -7,7 +7,7 @@ module.exports = function(original, options) { } removeTags.forEach(function(tag) { - result = result.replace(new RegExp('(\\s?)\/\/!' + tag + '-start((.|\n)*?)\/\/!' + tag + '-end', 'gim'), ''); + result = result.replace(new RegExp('(\\s?)\/\/!(\\s?)' + tag + '-start((.|\n)*?)\/\/!(\\s?)' + tag + '-end', 'gim'), ''); }); return result; diff --git a/lib/build/clean_test.js b/lib/build/clean_test.js new file mode 100644 index 00000000..248d755d --- /dev/null +++ b/lib/build/clean_test.js @@ -0,0 +1,15 @@ +var assert = require("assert"); +var clean = require("./clean"); + +describe("cleanAddress", function() { + var source = "123\n//!steal-remove-start\n456\n//!steal-remove-end\n789"; + var source2 = "123\n//! steal-remove-start\n456\n//! steal-remove-end\n789"; + + it("removes blocks surrounded with steal-remove-start and -end", function() { + assert.equal(clean(source, {}), "123\n789"); + }); + + it("allows an extra space before steal-remove-start for standard linting", function() { + assert.equal(clean(source2, {}), "123\n789"); + }); +});