From ccee7c1732fe96007b4a2774393a06d15ba92306 Mon Sep 17 00:00:00 2001 From: Craig Spence Date: Sun, 8 Apr 2018 21:01:37 +1200 Subject: [PATCH 1/2] fix(preprocessor): fix STYLE_URLS_REGEX to not break on multiple new lines --- __tests__/preprocessor.test.js | 19 +++++++++++++++++++ preprocessor.js | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/__tests__/preprocessor.test.js b/__tests__/preprocessor.test.js index 2dc3289625..41b833afc5 100644 --- a/__tests__/preprocessor.test.js +++ b/__tests__/preprocessor.test.js @@ -26,6 +26,25 @@ const sources = [ '../media-box.component.scss', './media-box-h0.component.scss' ], +})`, + `@Component({ + selector: 'xc-media-box-h0', + templateUrl: 'media-box-h0.component.html', + styleUrls: [ + '../../box.component.scss', + '../media-box.component.scss', + './media-box-h0.component.scss' + ], +})`, + `@Component({ + selector: 'xc-media-box-h0', + templateUrl: 'media-box-h0.component.html', + styleUrls: [ + '../../../box.component.scss', + '../../box.component.scss', + '../media-box.component.scss', + './media-box-h0.component.scss' + ], })` ]; diff --git a/preprocessor.js b/preprocessor.js index 46e007619e..04ac7a1a8f 100644 --- a/preprocessor.js +++ b/preprocessor.js @@ -1,6 +1,6 @@ const process = require('ts-jest/preprocessor.js').process; const TEMPLATE_URL_REGEX = /templateUrl:\s*('|")(\.\/){0,}(.*)('|")/g; -const STYLE_URLS_REGEX = /styleUrls:\s*\[\s*((?:'|").*\s*(?:'|")).*\s*.*\]/g; +const STYLE_URLS_REGEX = /styleUrls:\s*\[[^\]]*\]/g; const ESCAPE_TEMPLATE_REGEX = /(\${|\`)/g; module.exports.process = (src, path, config, transformOptions) => { From db7f016484af8bc7ab9baea378724bf881bd7ac3 Mon Sep 17 00:00:00 2001 From: Craig Spence Date: Sun, 8 Apr 2018 21:01:37 +1200 Subject: [PATCH 2/2] fix(preprocessor): fix STYLE_URLS_REGEX to not break on multiple new lines Fixes #136 --- __tests__/preprocessor.test.js | 19 +++++++++++++++++++ preprocessor.js | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/__tests__/preprocessor.test.js b/__tests__/preprocessor.test.js index 2dc3289625..41b833afc5 100644 --- a/__tests__/preprocessor.test.js +++ b/__tests__/preprocessor.test.js @@ -26,6 +26,25 @@ const sources = [ '../media-box.component.scss', './media-box-h0.component.scss' ], +})`, + `@Component({ + selector: 'xc-media-box-h0', + templateUrl: 'media-box-h0.component.html', + styleUrls: [ + '../../box.component.scss', + '../media-box.component.scss', + './media-box-h0.component.scss' + ], +})`, + `@Component({ + selector: 'xc-media-box-h0', + templateUrl: 'media-box-h0.component.html', + styleUrls: [ + '../../../box.component.scss', + '../../box.component.scss', + '../media-box.component.scss', + './media-box-h0.component.scss' + ], })` ]; diff --git a/preprocessor.js b/preprocessor.js index 46e007619e..04ac7a1a8f 100644 --- a/preprocessor.js +++ b/preprocessor.js @@ -1,6 +1,6 @@ const process = require('ts-jest/preprocessor.js').process; const TEMPLATE_URL_REGEX = /templateUrl:\s*('|")(\.\/){0,}(.*)('|")/g; -const STYLE_URLS_REGEX = /styleUrls:\s*\[\s*((?:'|").*\s*(?:'|")).*\s*.*\]/g; +const STYLE_URLS_REGEX = /styleUrls:\s*\[[^\]]*\]/g; const ESCAPE_TEMPLATE_REGEX = /(\${|\`)/g; module.exports.process = (src, path, config, transformOptions) => {