Skip to content

Instantly share code, notes, and snippets.

@steckel
Created February 10, 2017 17:03
Show Gist options
  • Save steckel/536e15ac846ed4853fda9f9836518907 to your computer and use it in GitHub Desktop.
Save steckel/536e15ac846ed4853fda9f9836518907 to your computer and use it in GitHub Desktop.
const execFile = require('child_process').execFile;
const flow = require('flow-bin');
function FlowPlugin(options) {
}
FlowPlugin.prototype.apply = function(compiler) {
var errors = [];
function flowCheck() {
var cb = arguments[arguments.length - 1];
execFile(flow, ['check'], (err, result) => {
if (err !== null) {
errors.push(new Error(result));
}
cb();
});
}
compiler.plugin("run", flowCheck);
compiler.plugin("watch-run", flowCheck);
compiler.plugin("compilation", function(compilation) {
errors.forEach((error) => compilation.errors.push(error));
errors = [];
});
};
module.exports = FlowPlugin;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment