Fail build if elm-optimize-level-2 isn't found, and print error output (for example if Debug.log's are found).

This commit is contained in:
Dillon Kearns 2021-07-26 12:40:50 -07:00
parent d22d2bebaf
commit 449e32cf9c

View File

@ -152,7 +152,18 @@ function elmOptimizeLevel2(elmEntrypointPath, outputPath, cwd) {
cwd: cwd,
}
);
let commandOutput = "";
subprocess.stderr.on("data", function (data) {
commandOutput += data;
});
subprocess.on("exit", async (code) => {
if (code !== 0) {
process.exitCode = 1;
reject(commandOutput);
}
});
subprocess.on("close", async (code) => {
if (code == 0 && (await fs.fileExists(fullOutputPath))) {
resolve();
@ -173,11 +184,7 @@ async function spawnElmMake(options, elmEntrypointPath, outputPath, cwd) {
if (options.debug) {
await runElmMake(elmEntrypointPath, outputPath, cwd);
} else {
try {
await elmOptimizeLevel2(elmEntrypointPath, outputPath, cwd);
} catch (error) {
await runElmMake(elmEntrypointPath, outputPath, cwd);
}
await elmOptimizeLevel2(elmEntrypointPath, outputPath, cwd);
}
}