Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Commit

Permalink
Fix not returning execution flow control to webpack when cache option…
Browse files Browse the repository at this point in the history
… is enabled and one of the files has a linting error (#224)

* Fix webpack hanging when `failOnError` and  are enabled and there is a formatting error

* Add tests for the combination of emit+async+failOnError
  • Loading branch information
nicolaslt authored and MoOx committed Jul 19, 2018
1 parent 1dc9442 commit 97761d7
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,14 @@ module.exports = function(input, map) {
if (err) {
return callback(err)
}
printLinterOutput(res || {}, config, webpack)
return callback(null, input, map)

try {
printLinterOutput(res || {}, config, webpack)
}
catch (e) {
err = e
}
return callback(err, input, map)
}
)
}
Expand Down
56 changes: 56 additions & 0 deletions test/fail-on-error/async-and-emit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
var test = require("ava")

var webpack = require("webpack")
var conf = require("./utils/conf")

test.cb("emits errors in async mode", function(t) {
t.plan(1)
webpack(conf(
{
cache: true,
entry: "./test/fixtures/error.js",
},{
failOnError: true,
emitError: true,
cache: true,
}
),
function(err, stats) {
if (err) {
throw err
}

// console.log(stats.compilation.errors)
t.true(
stats.hasErrors(),
"a file that contains eslint errors should return error"
)
t.end()
})
})

test.cb("correctly indentifies a success", function(t) {
t.plan(1)
webpack(conf(
{
cache: true,
entry: "./test/fixtures/good.js",
},{
failOnError: true,
emitError: true,
cache: true,
}
),
function(err, stats) {
if (err) {
throw err
}

// console.log(stats.compilation.errors)
t.false(
stats.hasErrors(),
"a file that doesn't contains eslint errors should not return errors"
)
t.end()
})
})

0 comments on commit 97761d7

Please sign in to comment.