From 37dd3fe2b862c7e10a017e89f5d37e3a3df11aad Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Thu, 17 Dec 2020 12:25:39 -0500 Subject: [PATCH] Replace bash prepare script with node version --- package.json | 2 +- scripts/prepare.js | 12 ++++++++++++ scripts/prepare.sh | 5 ----- 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100755 scripts/prepare.js delete mode 100755 scripts/prepare.sh diff --git a/package.json b/package.json index f9984a2dc..25338adcb 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 000000000..898b105e2 --- /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 bde12b36a..000000000 --- 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