diff --git a/middleware.js b/middleware.js index 291d6e2ac..f0df0f645 100644 --- a/middleware.js +++ b/middleware.js @@ -86,7 +86,7 @@ module.exports = function(compiler, options) { var cbs = callbacks; callbacks = []; cbs.forEach(function continueBecauseBundleAvailable(cb) { - cb(); + cb(stats); }); }); @@ -130,7 +130,7 @@ module.exports = function(compiler, options) { // wait for bundle valid function ready(fn, req) { - if(state) return fn(); + if(state) return fn(webpackStats); if(!options.noInfo && !options.quiet) options.log("webpack: wait until bundle finished: " + (req.url || fn.name)); callbacks.push(fn); diff --git a/test/API.test.js b/test/API.test.js index ee3d3f672..11dbb2954 100644 --- a/test/API.test.js +++ b/test/API.test.js @@ -64,7 +64,9 @@ describe("Advanced API", function() { var instance = middleware(compiler, options); plugins.done(doneStats); setTimeout(function() { - instance.waitUntilValid(done); + instance.waitUntilValid(function() { + done(); + }); }); }); @@ -75,6 +77,17 @@ describe("Advanced API", function() { instance.waitUntilValid(); }); }); + + it("callback should have stats argument", function(done) { + var instance = middleware(compiler, options); + plugins.done(doneStats); + setTimeout(function() { + instance.waitUntilValid(function(stats) { + should(stats).have.keys('hasErrors', 'hasWarnings'); + done(); + }); + }); + }); }); describe("invalidate", function() {