flow-webpack-plugin icon indicating copy to clipboard operation
flow-webpack-plugin copied to clipboard

`flowPath` doesn't allow you to omit local flow

Open colehaus opened this issue 7 years ago • 0 comments

If you set flowPath to a globally installed flow without any local flow, this plugin still throws an error like:

Error: `flow` can't be found. Please either install it (`npm install --save-dev flow-bin`) or set `flowPath` option
    at FlowWebpackPluginError (.../flow-webpack-plugin/dist/index.js:262:1)
    at getLocalFlowPath (.../flow-webpack-plugin/dist/index.js:200:28)
    at applyOptionsDefaults (.../flow-webpack-plugin/dist/index.js:254:19)
    at new FlowWebpackPlugin (.../flow-webpack-plugin/dist/index.js:27:20)
    ...

.

I'd expect to be able to direct the plugin to my global flow and for this to all work without any local flow install.

I think the reason that it fails is that applyOptionDefaults calls getLocalFlowPath too eagerly. That function throws the exception but is always called---even when a flowPath is provided. Instead, it should be a thunk or something analogous and only called if flowPath is missing.

colehaus avatar Mar 31 '18 00:03 colehaus