mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2025-01-05 12:57:33 +03:00
Capture elm compiler errors in order to log them cleanly without overlapping process logs.
This commit is contained in:
parent
22c5fc968d
commit
c85a5e82f4
@ -47,7 +47,11 @@ async function run(options) {
|
|||||||
const cliDone = runCli(options);
|
const cliDone = runCli(options);
|
||||||
const compileClientDone = compileElm(options);
|
const compileClientDone = compileElm(options);
|
||||||
|
|
||||||
await Promise.all([copyDone, cliDone, compileClientDone]);
|
try {
|
||||||
|
await Promise.all([copyDone, cliDone, compileClientDone]);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initWorker() {
|
function initWorker() {
|
||||||
@ -140,13 +144,18 @@ function spawnElmMake(options, elmEntrypointPath, outputPath, cwd) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
const subprocess = runElm(options, elmEntrypointPath, outputPath, cwd);
|
const subprocess = runElm(options, elmEntrypointPath, outputPath, cwd);
|
||||||
|
let commandOutput = "";
|
||||||
|
|
||||||
|
subprocess.stderr.on("data", function (data) {
|
||||||
|
commandOutput += data;
|
||||||
|
});
|
||||||
|
|
||||||
subprocess.on("close", async (code) => {
|
subprocess.on("close", async (code) => {
|
||||||
if (code == 0 && (await fs.fileExists(fullOutputPath))) {
|
if (code == 0 && (await fs.fileExists(fullOutputPath))) {
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
reject();
|
reject(restoreColor(JSON.parse(commandOutput).errors));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -159,24 +168,34 @@ function spawnElmMake(options, elmEntrypointPath, outputPath, cwd) {
|
|||||||
*/
|
*/
|
||||||
function runElm(options, elmEntrypointPath, outputPath, cwd) {
|
function runElm(options, elmEntrypointPath, outputPath, cwd) {
|
||||||
if (options.debug) {
|
if (options.debug) {
|
||||||
console.log("Running elm make");
|
// console.log("Running elm make");
|
||||||
return spawnCallback(
|
return spawnCallback(
|
||||||
`elm`,
|
`elm`,
|
||||||
["make", elmEntrypointPath, "--output", outputPath, "--debug"],
|
[
|
||||||
|
"make",
|
||||||
|
elmEntrypointPath,
|
||||||
|
"--output",
|
||||||
|
outputPath,
|
||||||
|
"--debug",
|
||||||
|
"--report",
|
||||||
|
"json",
|
||||||
|
],
|
||||||
{
|
{
|
||||||
// ignore stdout
|
// ignore stdout
|
||||||
stdio: ["inherit", "ignore", "inherit"],
|
// stdio: ["inherit", "ignore", "inherit"],
|
||||||
|
|
||||||
cwd: cwd,
|
cwd: cwd,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.log("Running elm-optimize-level-2");
|
// console.log("Running elm-optimize-level-2");
|
||||||
return spawnCallback(
|
return spawnCallback(
|
||||||
`elm-optimize-level-2`,
|
`elm-optimize-level-2`,
|
||||||
[elmEntrypointPath, "--output", outputPath],
|
[elmEntrypointPath, "--output", outputPath, "--report", "json"],
|
||||||
{
|
{
|
||||||
// ignore stdout
|
// ignore stdout
|
||||||
stdio: ["inherit", "ignore", "inherit"],
|
// stdio: ["inherit", "ignore", "inherit"],
|
||||||
|
|
||||||
cwd: cwd,
|
cwd: cwd,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user