From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- node_modules/time-fix-plugin/index.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 node_modules/time-fix-plugin/index.js (limited to 'node_modules/time-fix-plugin/index.js') diff --git a/node_modules/time-fix-plugin/index.js b/node_modules/time-fix-plugin/index.js new file mode 100644 index 00000000..4b7eb0f0 --- /dev/null +++ b/node_modules/time-fix-plugin/index.js @@ -0,0 +1,32 @@ +module.exports = class TimeFixPlugin { + constructor(watchOffset = 11000) { + this.watchOffset = watchOffset + } + + apply(compiler) { + const context = this + const watch = compiler.watch + let watching + + // Modify the time for first run + compiler.watch = function () { + watching = watch.apply(this, arguments) + watching.startTime += context.watchOffset + return watching + } + + // Modify the time for subsequent runs + compiler.hooks.watchRun.tap('time-fix-plugin', () => { + if (watching) { + watching.startTime += this.watchOffset + } + }) + + // Reset time + compiler.hooks.done.tap('time-fix-plugin', stats => { + if (watching) { + stats.startTime -= this.watchOffset + } + }) + } +} -- cgit v1.2.3