From 2c9cf00126dae2938eeb411d525959ca2ae13975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Mon, 8 Aug 2022 22:17:17 +0200 Subject: [PATCH] Fix source formatting for some examples For some css or html files a missing new line at end of file will concatenate the last line with the following style or script tag --- examples/webpack/example-builder.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/webpack/example-builder.js b/examples/webpack/example-builder.js index 4494f8d1aa..e2172a005d 100644 --- a/examples/webpack/example-builder.js +++ b/examples/webpack/example-builder.js @@ -262,6 +262,13 @@ export default class ExampleBuilder { }); } + ensureNewLineAtEnd(source) { + if (source[source.length - 1] !== '\n') { + source += '\n'; + } + return source; + } + transformJsSource(source) { return ( source @@ -298,8 +305,7 @@ export default class ExampleBuilder { let jsSource = await fse.readFile(jsPath, {encoding: 'utf8'}); jsSource = this.transformJsSource(this.cloakSource(jsSource, data.cloak)); data.js = { - tag: ` - `, + scripts: [`${this.common}.js`, jsName], source: jsSource, }; @@ -359,7 +365,7 @@ export default class ExampleBuilder { if (cssSource) { data.css = { tag: ``, - source: cssSource, + source: this.ensureNewLineAtEnd(cssSource), }; assets[cssName] = cssSource; }