Skip to content

Commit

Permalink
Expose stats (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist authored and SpaceK33z committed Sep 20, 2016
1 parent ab17c1b commit d5e0e9b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = function(compiler, options) {
var cbs = callbacks;
callbacks = [];
cbs.forEach(function continueBecauseBundleAvailable(cb) {
cb();
cb(stats);
});
});

Expand Down Expand Up @@ -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);
Expand Down
15 changes: 14 additions & 1 deletion test/API.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});

Expand All @@ -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() {
Expand Down

0 comments on commit d5e0e9b

Please sign in to comment.