Created
February 10, 2017 17:03
-
-
Save steckel/536e15ac846ed4853fda9f9836518907 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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