Skip to content

Commit 957b179

Browse files
committed
Merge pull request #19 from jhuntoo/fix-error-reporting
Output errors in exception when bail is enabled in webapck
2 parents 111eaac + 2560b98 commit 957b179

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ function lint(input, options) {
5353
merge(options, this.options.tslint);
5454
}
5555

56+
var bailEnabled = (this.options.bail === true);
57+
5658
//Override options in tslint.json by those passed to the loader as a query string
5759
var query = loaderUtils.parseQuery(this.query);
5860
merge(options, query);
@@ -61,19 +63,23 @@ function lint(input, options) {
6163
var result = linter.lint();
6264
var emitter = options.emitErrors ? this.emitError : this.emitWarning;
6365

64-
report(result, emitter, options.failOnHint, options.fileOutput);
66+
report(result, emitter, options.failOnHint, options.fileOutput, this.resourcePath, bailEnabled);
6567
}
6668

67-
function report(result, emitter, failOnHint, fileOutputOpts) {
69+
function report(result, emitter, failOnHint, fileOutputOpts, filename, bailEnabled) {
6870
if(result.failureCount === 0) return;
6971
emitter(result.output);
7072

7173
if(fileOutputOpts && fileOutputOpts.dir) {
7274
writeToFile(fileOutputOpts, result);
7375
}
7476

75-
if(failOnHint) {
76-
throw new Error("Compilation failed due to tslint errors.");
77+
if(failOnHint) {
78+
var messages = "";
79+
if (bailEnabled){
80+
messages = "\n\n" + filename + "\n" + result.output;
81+
}
82+
throw new Error("Compilation failed due to tslint errors." + messages);
7783
}
7884
}
7985

0 commit comments

Comments
 (0)