fix ProgressPlugin log
This commit is contained in:
parent
8d509e37a4
commit
a9ada9f919
|
@ -28,6 +28,7 @@ const median3 = (a, b, c) => {
|
|||
};
|
||||
|
||||
const createDefaultHandler = (profile, logger) => {
|
||||
let wasLogged = false;
|
||||
/** @type {{ value: string, time: number }[]} */
|
||||
const lastStateInfo = [];
|
||||
|
||||
|
@ -86,6 +87,10 @@ const createDefaultHandler = (profile, logger) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (percentage === 0 && !wasLogged) {
|
||||
wasLogged = true;
|
||||
return;
|
||||
}
|
||||
logger.status(`${Math.floor(percentage * 100)}%`, msg, ...args);
|
||||
if (percentage === 1 || (!msg && args.length === 0)) logger.status();
|
||||
};
|
||||
|
@ -537,9 +542,8 @@ class ProgressPlugin {
|
|||
handler(0, "");
|
||||
}
|
||||
});
|
||||
interceptHook(compiler.hooks.initialize, 0.01, "setup", "initialize");
|
||||
interceptHook(compiler.hooks.beforeRun, 0.02, "setup", "before run");
|
||||
interceptHook(compiler.hooks.run, 0.03, "setup", "run");
|
||||
interceptHook(compiler.hooks.beforeRun, 0.01, "setup", "before run");
|
||||
interceptHook(compiler.hooks.run, 0.02, "setup", "run");
|
||||
interceptHook(compiler.hooks.watchRun, 0.03, "setup", "watch run");
|
||||
interceptHook(
|
||||
compiler.hooks.normalModuleFactory,
|
||||
|
|
|
@ -37,16 +37,17 @@ const createSimpleCompiler = progressOptions => {
|
|||
entry: "./a.js",
|
||||
infrastructureLogging: {
|
||||
debug: /Progress/
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new webpack.ProgressPlugin({
|
||||
activeModules: true,
|
||||
...progressOptions
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||
|
||||
new webpack.ProgressPlugin({
|
||||
activeModules: true,
|
||||
...progressOptions
|
||||
}).apply(compiler);
|
||||
|
||||
return compiler;
|
||||
};
|
||||
|
||||
|
@ -115,6 +116,15 @@ describe("ProgressPlugin", function () {
|
|||
nanTest(() => createMultiCompiler(undefined, { parallelism: 1 }))
|
||||
);
|
||||
|
||||
it("should start print only on call run/watch", done => {
|
||||
const compiler = createSimpleCompiler();
|
||||
|
||||
const logs = getLogs(stderr.toString());
|
||||
expect(logs.join("")).toHaveLength(0);
|
||||
|
||||
compiler.close(done);
|
||||
});
|
||||
|
||||
it("should print profile information", () => {
|
||||
const compiler = createSimpleCompiler({
|
||||
profile: true
|
||||
|
|
Loading…
Reference in New Issue