mirror of
https://github.com/status-im/sourcecred.git
synced 2025-01-10 12:46:16 +00:00
480bdf1bc7
Summary: We were asking the `clean-webpack-plugin` to remove the `build/` directory in all cases. However, Webpack accepts a command-line parameter `--output-path`. When such a parameter is passed, we would be removing the wrong directory. The proper behavior is to remove “whatever the actual output path is”. Webpack exposes this information, but it appears that the `clean-webpack-plugin` does not take advantage of it. Therefore, this commit includes a small Webpack plugin to do the right thing. Test Plan: Test that the behavior is correct when no output directory is specified: ``` mkdir -p build && touch build/wat && yarn build && ! [ -e build/wat ] ``` Test that the behavior is correct with an explicit `--output-path`: ``` outdir="$(mktemp -d)" && touch "${outdir}/wat" && \ yarn build --output-path "${outdir}" && \ ! [ -e "${outdir}/wat" ] ``` Test that the plugin refuses to remove the root directory: ``` ! yarn build --output-path . && \ sed -i '/path: /d' config/makeWebpackConfig.js && ! yarn build ``` (Feel free to comment out the actual `rimraf.sync` line in the plugin when testing this.) wchargin-branch: clean-actual-build-directory