diff --git a/index.js b/index.js index 49e68ac..c3d3fbb 100644 --- a/index.js +++ b/index.js @@ -27,6 +27,7 @@ function applyReplacements (buffer, {commentTypes, conditions}) { if (buffer.length > 0) { for (const [key, value] of conditions) { for (const [commentStart, commentEnd] of commentTypes) { + // console.log(commentStart + commentEnd); const regex = getRemovalTagsRegExp(commentStart, commentEnd, key) contents = contents.replace(regex, function (ignore, original, capture) { @@ -56,6 +57,7 @@ function getRemovalTagsRegExp (commentStart, commentEnd, key) { const escapedCommentStart = escapeStringRegexp(commentStart) const escapedKey = escapeStringRegexp(key) const escapedCommentEnd = escapeStringRegexp(commentEnd) + const pattern = [ '(', escapedCommentStart, @@ -70,6 +72,15 @@ function getRemovalTagsRegExp (commentStart, commentEnd, key) { escapedKey, '\\)\\s*', escapedCommentEnd, + ')', + '|', + '(', + '.*', + escapedCommentStart, + '\\s*removeSingleIf\\((!?)', + escapedKey, + '\\)\\s*', + escapedCommentEnd, ')' ].join('') const re = new RegExp(pattern, 'gi')