Fix async io not awaited and don't crash if .ftl files does not exist for some reason
This commit is contained in:
parent
4f11415107
commit
f57f311aab
@ -16,6 +16,7 @@ import { isInside } from "../../tools/isInside";
|
||||
import child_process from "child_process";
|
||||
import { rmSync } from "../../tools/fs.rmSync";
|
||||
import { writeMetaInfKeycloakThemes } from "../../shared/metaInfKeycloakThemes";
|
||||
import { existsAsync } from "../../tools/fs.existsAsync";
|
||||
|
||||
export type BuildContextLike = BuildContextLike_generatePom & {
|
||||
keycloakifyBuildDirPath: string;
|
||||
@ -135,8 +136,10 @@ export async function buildJar(params: {
|
||||
break route_legacy_pages;
|
||||
}
|
||||
|
||||
(["register.ftl", "login-update-profile.ftl"] as const).forEach(pageId =>
|
||||
buildContext.themeNames.map(themeName => {
|
||||
await Promise.all(
|
||||
(["register.ftl", "login-update-profile.ftl"] as const)
|
||||
.map(pageId =>
|
||||
buildContext.themeNames.map(async themeName => {
|
||||
const ftlFilePath = pathJoin(
|
||||
tmpResourcesDirPath,
|
||||
"theme",
|
||||
@ -145,6 +148,11 @@ export async function buildJar(params: {
|
||||
pageId
|
||||
);
|
||||
|
||||
// NOTE: https://github.com/keycloakify/keycloakify/issues/665
|
||||
if (!(await existsAsync(ftlFilePath))) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ftlFileContent = readFileSync(ftlFilePath).toString("utf8");
|
||||
|
||||
const ftlFileBasename = (() => {
|
||||
@ -164,11 +172,13 @@ export async function buildJar(params: {
|
||||
|
||||
assert(modifiedFtlFileContent !== ftlFileContent);
|
||||
|
||||
fs.writeFile(
|
||||
await fs.writeFile(
|
||||
pathJoin(pathDirname(ftlFilePath), ftlFileBasename),
|
||||
Buffer.from(modifiedFtlFileContent, "utf8")
|
||||
);
|
||||
})
|
||||
)
|
||||
.flat()
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user