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
This commit is contained in:
@@ -262,6 +262,13 @@ export default class ExampleBuilder {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ensureNewLineAtEnd(source) {
|
||||||
|
if (source[source.length - 1] !== '\n') {
|
||||||
|
source += '\n';
|
||||||
|
}
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
transformJsSource(source) {
|
transformJsSource(source) {
|
||||||
return (
|
return (
|
||||||
source
|
source
|
||||||
@@ -298,8 +305,7 @@ export default class ExampleBuilder {
|
|||||||
let jsSource = await fse.readFile(jsPath, {encoding: 'utf8'});
|
let jsSource = await fse.readFile(jsPath, {encoding: 'utf8'});
|
||||||
jsSource = this.transformJsSource(this.cloakSource(jsSource, data.cloak));
|
jsSource = this.transformJsSource(this.cloakSource(jsSource, data.cloak));
|
||||||
data.js = {
|
data.js = {
|
||||||
tag: `<script src="${this.common}.js"></script>
|
scripts: [`${this.common}.js`, jsName],
|
||||||
<script src="${jsName}"></script>`,
|
|
||||||
source: jsSource,
|
source: jsSource,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -359,7 +365,7 @@ export default class ExampleBuilder {
|
|||||||
if (cssSource) {
|
if (cssSource) {
|
||||||
data.css = {
|
data.css = {
|
||||||
tag: `<link rel="stylesheet" href="${cssName}">`,
|
tag: `<link rel="stylesheet" href="${cssName}">`,
|
||||||
source: cssSource,
|
source: this.ensureNewLineAtEnd(cssSource),
|
||||||
};
|
};
|
||||||
assets[cssName] = cssSource;
|
assets[cssName] = cssSource;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user