Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix lint on change #20

Merged
Merged
Changes from 1 commit
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Next

fix lint on change regression

  • Loading branch information
trickpattyFH20 committed Mar 29, 2018
commit 3bbdfe584b7d5a8b4822e2c9aa9a94b7f29c8cc0
@@ -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 = [
ProTip! Use n and p to navigate between commits in a pull request.