flow-status-webpack-plugin
Advanced tools
Comparing version 0.1.7 to 0.1.8
39
index.js
@@ -29,8 +29,7 @@ var shell = require('shelljs'); | ||
function startFlowIfFirstRun(compiler, cb) { | ||
function startFlowIfFirstRun(cb) { | ||
if (firstRun) { | ||
firstRun = false; | ||
startFlow(cb); | ||
} | ||
else { | ||
} else { | ||
cb(); | ||
@@ -55,9 +54,8 @@ } | ||
var flowError = null | ||
var flowError = null; | ||
function checkItWreckIt(compiler, cb) { | ||
startFlowIfFirstRun(compiler, function () { | ||
function checkItWreckIt(cb) { | ||
startFlowIfFirstRun(function () { | ||
flowStatus(function success(stdout) { | ||
onSuccess(stdout); | ||
cb(); | ||
@@ -68,18 +66,19 @@ }, function error(stdout) { | ||
flowError = new Error(stdout); | ||
// Here we don't pass error to callback because | ||
// webpack-dev-middleware would just throw it | ||
// and cause webpack dev server to exit with | ||
// an error status code. Obviously, having to restart | ||
// the development webpack server after every flow | ||
// check error would be too annoying. | ||
cb() | ||
}) | ||
}) | ||
// Do not pass error to callback to avoid dev server exit | ||
cb(); | ||
}); | ||
}); | ||
} | ||
compiler.plugin('run', checkItWreckIt); | ||
compiler.plugin('watch-run', checkItWreckIt); | ||
// Webpack 5 hooks | ||
compiler.hooks.run.tapAsync('FlowStatusWebpackPlugin', (compilation, callback) => { | ||
checkItWreckIt(callback); | ||
}); | ||
// If there are flow errors, fail the build before compilation starts. | ||
compiler.plugin('compilation', function (compilation) { | ||
compiler.hooks.watchRun.tapAsync('FlowStatusWebpackPlugin', (compilation, callback) => { | ||
checkItWreckIt(callback); | ||
}); | ||
// Add errors to compilation if needed | ||
compiler.hooks.compilation.tap('FlowStatusWebpackPlugin', (compilation) => { | ||
if (flowError) { | ||
@@ -86,0 +85,0 @@ if (failOnError === true) { |
{ | ||
"name": "flow-status-webpack-plugin", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"author": "Diego Durli <dgodurli@gmail> (https://github.com/diegodurli)", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
8793
11
75
1