Closed luis-soares-sky closed 1 day ago
Hmm. So, I'm not sure a rejected promise is the right answer here, and I'm not sure what result
would be. In your .then()
function, you can easily check
if(builder.program.getDiagnostics().filter(x=> x.severity=== DiagnosticSeverity.Error).length > 0){
throw new Error("Encountered error diagnostics");
};```
What if you wanted to fail for warnings too, but our default is to only fail on errors?
If the builder fails to output any BRS or XML files due to errors, which could be considered invalid output, then I'd argue that the promise should be rejected.
What if you wanted to fail for warnings too, but our default is to only fail on errors?
In an ideal world, it could be configured. Some pseudo-code:
enum FailureLevel {
None, // default
OnErrors,
OnWarnings
}
builder.run({
failThreshold: FailureLevel.OnWarnings
})
Already using the solution proposed by Bronley which is enough for our purposes.
ProgramBuilder.run()
is currently an async method that doesn't return any value, regardless if the build is successful or not. This prevents us from easily interrupting our build process when Brighterscript fails to transpile.Given this example gulp task:
Because the builder will never return a value even when there are errors, the promise will fire all resolve handlers without any
result
, and in our case, gulp will keep chugging on. This results in a broken build where most of the files will be missing.A possible solution would be to return the result of
runOnce()
, or to throw when the number of errors is!= 0
, but I'm not sure how it would work with watch mode...