Commit fbb2aba0 authored by Hunter Loftis's avatar Hunter Loftis

Merge pull request #184 from heroku/trap-function-errs

traps errors in functions
parents 630c1caa 070d0a94
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
set -e # fail fast set -e # fail fast
set -o pipefail # don't ignore exit codes when piping output set -o pipefail # don't ignore exit codes when piping output
set -o errtrace # trap errors in functions as well
# set -x # enable debugging # set -x # enable debugging
# Configure directories # Configure directories
...@@ -65,34 +66,7 @@ install_npm ...@@ -65,34 +66,7 @@ install_npm
head "Building dependencies" head "Building dependencies"
cd $build_dir cd $build_dir
build_dependencies
if [ "$modules_source" == "" ]; then
info "Skipping dependencies (no source for node_modules)"
elif [ "$modules_source" == "prebuilt" ]; then
info "Rebuilding any native modules for this architecture"
npm rebuild 2>&1 | indent
info "Installing any new modules"
npm install --quiet --userconfig $build_dir/.npmrc 2>&1 | indent
else
cache_status=$(get_cache_status)
if [ "$cache_status" == "valid" ]; then
info "Restoring node modules from cache"
cp -r $cache_dir/node/node_modules $build_dir/
info "Pruning unused dependencies"
npm prune 2>&1 | indent
info "Installing any new modules"
npm install --quiet --userconfig $build_dir/.npmrc 2>&1 | indent
else
info "$cache_status"
info "Installing node modules"
touch $build_dir/.npmrc
npm install --quiet --userconfig $build_dir/.npmrc 2>&1 | indent
fi
fi
####### Create a Procfile if possible ####### Create a Procfile if possible
......
...@@ -130,6 +130,35 @@ install_npm() { ...@@ -130,6 +130,35 @@ install_npm() {
fi fi
} }
function build_dependencies() {
if [ "$modules_source" == "" ]; then
info "Skipping dependencies (no source for node_modules)"
elif [ "$modules_source" == "prebuilt" ]; then
info "Rebuilding any native modules for this architecture"
npm rebuild 2>&1 | indent
info "Installing any new modules"
npm install --quiet --userconfig $build_dir/.npmrc 2>&1 | indent
else
cache_status=$(get_cache_status)
if [ "$cache_status" == "valid" ]; then
info "Restoring node modules from cache"
cp -r $cache_dir/node/node_modules $build_dir/
info "Pruning unused dependencies"
npm prune 2>&1 | indent
info "Installing any new modules"
npm install --quiet --userconfig $build_dir/.npmrc 2>&1 | indent
else
info "$cache_status"
info "Installing node modules"
touch $build_dir/.npmrc
npm install --quiet --userconfig $build_dir/.npmrc 2>&1 | indent
fi
fi
}
ensure_procfile() { ensure_procfile() {
local start_method=$1 local start_method=$1
local build_dir=$2 local build_dir=$2
......
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