Skip to content

Commit d5e0e9b

Browse files
egoistSpaceK33z
authored andcommitted
Expose stats (#127)
1 parent ab17c1b commit d5e0e9b

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

middleware.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ module.exports = function(compiler, options) {
8686
var cbs = callbacks;
8787
callbacks = [];
8888
cbs.forEach(function continueBecauseBundleAvailable(cb) {
89-
cb();
89+
cb(stats);
9090
});
9191
});
9292

@@ -130,7 +130,7 @@ module.exports = function(compiler, options) {
130130

131131
// wait for bundle valid
132132
function ready(fn, req) {
133-
if(state) return fn();
133+
if(state) return fn(webpackStats);
134134
if(!options.noInfo && !options.quiet)
135135
options.log("webpack: wait until bundle finished: " + (req.url || fn.name));
136136
callbacks.push(fn);

test/API.test.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ describe("Advanced API", function() {
6464
var instance = middleware(compiler, options);
6565
plugins.done(doneStats);
6666
setTimeout(function() {
67-
instance.waitUntilValid(done);
67+
instance.waitUntilValid(function() {
68+
done();
69+
});
6870
});
6971
});
7072

@@ -75,6 +77,17 @@ describe("Advanced API", function() {
7577
instance.waitUntilValid();
7678
});
7779
});
80+
81+
it("callback should have stats argument", function(done) {
82+
var instance = middleware(compiler, options);
83+
plugins.done(doneStats);
84+
setTimeout(function() {
85+
instance.waitUntilValid(function(stats) {
86+
should(stats).have.keys('hasErrors', 'hasWarnings');
87+
done();
88+
});
89+
});
90+
});
7891
});
7992

8093
describe("invalidate", function() {

0 commit comments

Comments
 (0)