Skip to content

Commit

Permalink
Add compiler errors to browser console (issue elm-community#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
wbyrnetx committed Apr 29, 2022
1 parent bbce36b commit 73d862c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function compile(sources, options) {
return reject(err);
}
options.output = info.path;
options.processOpts = { stdio: "inherit" };
options.processOpts = { stdio: "pipe" };

var compiler;

Expand All @@ -174,9 +174,14 @@ function compile(sources, options) {
return reject(compileError);
}

// Catch output from stderr so we can use it in resolve
var errorChunks = [];
compiler.stderr.on('data', (data) => errorChunks = errorChunks.concat(data));

compiler.on("close", function (exitCode) {
if (exitCode !== 0) {
return reject("Compilation failed");
var errorText = Buffer.concat(errorChunks).toString();
return reject("Compilation failed! " + errorText);
}

fs.readFile(info.path, { encoding: "utf8" }, function (err, data) {
Expand Down

0 comments on commit 73d862c

Please sign in to comment.