diff --git a/package.json b/package.json index 694e4bde9aa..e3d9ead57b1 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "scripts": { "start": "yarn serve", "serve": "webpack serve --config webpack.dev.js", - "prepare": "./scripts/prepare.sh", + "prepare": "node ./scripts/prepare.js", "build:development": "webpack --config webpack.dev.js", "build:production": "webpack --config webpack.prod.js", "lint": "eslint \"src/\"", diff --git a/scripts/prepare.js b/scripts/prepare.js new file mode 100755 index 00000000000..898b105e2f7 --- /dev/null +++ b/scripts/prepare.js @@ -0,0 +1,12 @@ +const { execSync } = require('child_process'); + +/** + * The npm `prepare` script needs to run a build to support installing + * a package from git repositories (this is dumb but a limitation of how + * npm behaves). We don't want to run these in CI though because + * building is slow so this script will skip the build when the + * `SKIP_PREPARE` environment variable has been set. + */ +if (!process.env.SKIP_PREPARE) { + execSync('webpack --config webpack.prod.js', { stdio: 'inherit' }); +} diff --git a/scripts/prepare.sh b/scripts/prepare.sh deleted file mode 100755 index bde12b36a59..00000000000 --- a/scripts/prepare.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -if [ -z "${SKIP_PREPARE}" ]; then - webpack --config webpack.prod.js -fi