Commit 649802e7 authored by Hunter Loftis's avatar Hunter Loftis

simplify a bit

parent 5085334c
...@@ -118,15 +118,14 @@ header "Restoring cache" ...@@ -118,15 +118,14 @@ header "Restoring cache"
restore_cache | output "$LOG_FILE" restore_cache | output "$LOG_FILE"
build_dependencies() { build_dependencies() {
local has_prebuild_script=$(read_json "$BUILD_DIR/package.json" ".scripts[\"heroku-prebuild\"]") run_if_present 'heroku-prebuild'
local has_postbuild_script=$(read_json "$BUILD_DIR/package.json" ".scripts[\"heroku-postbuild\"]")
if $PREBUILD; then if $PREBUILD; then
echo "Prebuild detected (node_modules already exists)" echo "Prebuild detected (node_modules already exists)"
rebuild_node_modules "$BUILD_DIR" "$has_prebuild_script" "$has_postbuild_script" rebuild_node_modules "$BUILD_DIR"
else else
install_node_modules "$BUILD_DIR" "$has_prebuild_script" "$has_postbuild_script" install_node_modules "$BUILD_DIR"
fi fi
run_if_present 'heroku-postbuild'
} }
header "Building dependencies" header "Building dependencies"
......
run_if_present() {
local script_name=${1:-}
local has_script=$(read_json "$BUILD_DIR/package.json" ".scripts[\"$script_name\"]")
if [ -n "$has_script" ]; then
echo "Running $script_name"
npm run "$script_name" --if-present
fi
}
install_node_modules() { install_node_modules() {
local build_dir=${1:-} local build_dir=${1:-}
local has_prebuild_script=${2:-} local has_prebuild_script=${2:-}
...@@ -5,10 +14,7 @@ install_node_modules() { ...@@ -5,10 +14,7 @@ install_node_modules() {
if [ -e $build_dir/package.json ]; then if [ -e $build_dir/package.json ]; then
cd $build_dir cd $build_dir
if [ -n "$has_prebuild_script" ]; then
echo "Running prebuild script"
npm run heroku-prebuild
fi
echo "Pruning any extraneous modules" echo "Pruning any extraneous modules"
npm prune --unsafe-perm --userconfig $build_dir/.npmrc 2>&1 npm prune --unsafe-perm --userconfig $build_dir/.npmrc 2>&1
if [ -e $build_dir/npm-shrinkwrap.json ]; then if [ -e $build_dir/npm-shrinkwrap.json ]; then
......
#!/usr/bin/env bash #!/usr/bin/env bash
# See README.md for info on running these tests. # See README.md for info on running these tests.
testPrePostBuildScripts() {
compile "pre-post-build-scripts"
assertCaptured "Running heroku-prebuild"
assertCaptured "echo heroku-prebuild hook message"
assertCaptured "Running heroku-postbuild"
assertCaptured "echo heroku-postbuild hook message"
assertCapturedSuccess
compile "stable-node"
assertNotCaptured "Running heroku-prebuild"
assertNotCaptured "Running heroku-postbuild"
assertCapturedSuccess
}
testWarningsOnFailure() { testWarningsOnFailure() {
compile "many-warnings" compile "many-warnings"
assertCaptured "troubleshooting-node-deploys" assertCaptured "troubleshooting-node-deploys"
...@@ -471,15 +485,6 @@ testMultiExport() { ...@@ -471,15 +485,6 @@ testMultiExport() {
assertCapturedSuccess assertCapturedSuccess
} }
testPrePostBuildScripts() {
compile "pre-post-build-scripts"
assertCaptured "Running prebuild script"
assertCaptured "echo heroku-prebuild hook message"
assertCaptured "Running postbuild script"
assertCaptured "echo heroku-postbuild hook message"
assertCapturedSuccess
}
# Utils # Utils
pushd $(dirname 0) >/dev/null pushd $(dirname 0) >/dev/null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment