Generate the postinstall script as the first entry of the package.json

This commit is contained in:
Joseph Garrone
2024-12-22 21:25:51 +01:00
parent 982f216a01
commit 96690e1354

View File

@ -15,8 +15,6 @@ export function addPostinstallScriptIfNotPresent(params: {
}) {
const { parsedPackageJson, buildContext } = params;
const scripts = (parsedPackageJson.scripts ??= {});
const cmd_base = "keycloakify postinstall";
const projectCliOptionValue = (() => {
@ -48,6 +46,9 @@ export function addPostinstallScriptIfNotPresent(params: {
return cmd;
};
{
const scripts = (parsedPackageJson.scripts ??= {});
for (const scriptName of ["postinstall", "prepare"]) {
const cmd_preexisting = scripts[scriptName];
@ -60,6 +61,10 @@ export function addPostinstallScriptIfNotPresent(params: {
return;
}
}
scripts["postinstall"] = generateCmd({ cmd_preexisting: scripts["postinstall"] });
}
parsedPackageJson.scripts = {
postinstall: generateCmd({ cmd_preexisting: undefined }),
...parsedPackageJson.scripts
};
}