From 3bbdfe584b7d5a8b4822e2c9aa9a94b7f29c8cc0 Mon Sep 17 00:00:00 2001 From: Patrick Lawler Date: Thu, 29 Mar 2018 18:38:13 -0400 Subject: [PATCH 1/3] fix lint on change regression --- webpack.config.js | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 5405d70c2..1d16ba529 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -64,7 +64,7 @@ const lintOnChange = function() { if (process.argv.includes('--env.fix')) { args.push('--', '--fix') } - lint = spawnSync('npm', args, { stdio: 'inherit'}); + let lint = spawnSync('npm', args, { stdio: 'inherit'}); if (lint.status !== 0) { process.exit(lint.status); } @@ -74,28 +74,19 @@ lintOnChange.prototype.apply = function(compiler) { if (process.argv.includes('--env.prod') || (process.argv.includes('--env.nolint') || process.env.NO_LINT)) { return; } - compiler.plugin('emit', function(compilation, callback) { - let changedFiles = Object.keys(compilation.fileTimestamps).filter(function(watchfile) { - return (this.prevTimestamps[watchfile] || this.startTime) < (compilation.fileTimestamps[watchfile] || Infinity); - }.bind(this)); - - changedFiles = changedFiles.filter((file) => { - return file.indexOf('.js') !== -1; - }); - - if(changedFiles.length > 0) { + compiler.plugin("watch-run", (watching, done) => { + const changedTimes = compiler.watchFileSystem.watcher.mtimes; + const changedFiles = Object.keys(changedTimes); + if (changedFiles.length) { const args = ['run', 'lint.raw', '--', ...changedFiles]; if (process.argv.includes('--env.fix')) { args.push('--fix') } - lint = spawnSync('npm', args, { stdio: 'inherit'}); + let lint = spawnSync('npm', args, { stdio: 'inherit'}); } + done(); + }); - this.startTime = Date.now(); - this.prevTimestamps = {}; - - callback(); - }.bind(this)); }; const buildPlugins = [ From a5dfd6990b3080459c574356cbbeaa89a118f1f2 Mon Sep 17 00:00:00 2001 From: Patrick Lawler Date: Fri, 30 Mar 2018 10:02:05 -0400 Subject: [PATCH 2/3] output lint after webpack output --- webpack.config.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 1d16ba529..dfe6994fc 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -74,7 +74,7 @@ lintOnChange.prototype.apply = function(compiler) { if (process.argv.includes('--env.prod') || (process.argv.includes('--env.nolint') || process.env.NO_LINT)) { return; } - compiler.plugin("watch-run", (watching, done) => { + compiler.plugin("done", (watching, done) => { const changedTimes = compiler.watchFileSystem.watcher.mtimes; const changedFiles = Object.keys(changedTimes); if (changedFiles.length) { @@ -82,11 +82,12 @@ lintOnChange.prototype.apply = function(compiler) { if (process.argv.includes('--env.fix')) { args.push('--fix') } - let lint = spawnSync('npm', args, { stdio: 'inherit'}); + setTimeout(() => { + spawnSync('npm', args, { stdio: 'inherit'}); + }); } done(); }); - }; const buildPlugins = [ From c13afec7295de7d180d029f94766b2add3fa4091 Mon Sep 17 00:00:00 2001 From: Patrick Lawler Date: Fri, 30 Mar 2018 10:23:26 -0400 Subject: [PATCH 3/3] done rr --- webpack.config.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index dfe6994fc..30aef7e0c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -74,7 +74,7 @@ lintOnChange.prototype.apply = function(compiler) { if (process.argv.includes('--env.prod') || (process.argv.includes('--env.nolint') || process.env.NO_LINT)) { return; } - compiler.plugin("done", (watching, done) => { + compiler.plugin("done", () => { const changedTimes = compiler.watchFileSystem.watcher.mtimes; const changedFiles = Object.keys(changedTimes); if (changedFiles.length) { @@ -86,7 +86,6 @@ lintOnChange.prototype.apply = function(compiler) { spawnSync('npm', args, { stdio: 'inherit'}); }); } - done(); }); };