Fix adding comment to certain ftl files

This commit is contained in:
Joseph Garrone 2025-01-06 02:31:46 +01:00
parent 813740a002
commit 249a7bde89

View File

@ -100,9 +100,19 @@ function addCommentToSourceCode(params: {
}
if (fileRelativePath.endsWith(".ftl")) {
return toResult(
[`<#--`, ...commentLines.map(line => ` ${line}`), `-->`].join("\n")
const comment = [`<#--`, ...commentLines.map(line => ` ${line}`), `-->`].join(
"\n"
);
if (sourceCode.trim().startsWith("<#ftl")) {
const [first, ...rest] = sourceCode.split(">");
const last = rest.join(">");
return [`${first}>`, comment, last].join("\n");
}
return toResult(comment);
}
if (fileRelativePath.endsWith(".html") || fileRelativePath.endsWith(".svg")) {