Commit c56b58c8 authored by zeke's avatar zeke

experiment

parent 1e9b4890
......@@ -2,7 +2,7 @@
set -e # fail fast
set -o pipefail # don't ignore exit codes when piping output
set -x # enable debugging
# set -x # enable debugging
# Configure directories
build_dir=$1
......@@ -17,18 +17,6 @@ source $bp_dir/bin/common.sh
# Output npm debug info on error
trap cat_npm_debug_log ERR
if [ "$env_file" ]; then
status "before:"
env
status "Here's your env_file:"
status "$env_file"
export $(egrep -v "^(PATH)" $env_file)
status "after:"
env
fi
# Look in package.json's engines.node field for a semver range
semver_range=$(cat $build_dir/package.json | $bp_dir/vendor/jq -r .engines.node)
......@@ -81,9 +69,17 @@ elif test -d $cache_dir/node_modules; then
npm prune 2>&1 | indent
fi
# Make npm output to STDOUT instead of its default STDERR
status "Installing dependencies"
npm install --userconfig $build_dir/.npmrc --production 2>&1 | indent
# Scope config var availability only to `npm install`
(
if [ "$env_file" ]; then
status "Importing application config vars"
export $(egrep -v "^(PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH)" "$env_file")
fi
status "Installing dependencies"
# Make npm output to STDOUT instead of its default STDERR
npm install --userconfig $build_dir/.npmrc --production 2>&1 | indent
)
status "Caching node_modules directory for future builds"
rm -rf $cache_dir
......
......@@ -104,6 +104,23 @@ testProcfileAbsentNpmStartAbsent() {
assertCapturedSuccess
}
testProcfileAbsentNpmStartPresent() {
compile "procfile-absent-npm-start-present"
assertCaptured "No Procfile found; Adding npm start to new Procfile"
assertFile "web: npm start" "Procfile"
assertCapturedSuccess
}
testEnvfileNotImported() {
compile "stable-node"
assertNotCaptured "Importing application config vars"
}
testEnvfileImported() {
compileWithEnv "stable-node"
assertCaptured "Importing application config vars"
}
# Pending Tests
# testNodeBinariesAddedToPath() {
......@@ -132,6 +149,8 @@ testProcfileAbsentNpmStartAbsent() {
# assertCapturedError 1 "not found among available versions"
# }
# Utils
pushd $(dirname 0) >/dev/null
......@@ -159,6 +178,13 @@ compile() {
capture ${bp_dir}/bin/compile ${compile_dir} ${2:-$(mktmpdir)}
}
compileWithEnv() {
compile_dir=$(mktmpdir)
env_file="FOO=1;BAR=2;"
cp -r ${bp_dir}/test/$1/. ${compile_dir}
capture ${bp_dir}/bin/compile ${compile_dir} ${2:-$(mktmpdir) $env_file}
}
assertFile() {
assertEquals "$1" "$(cat ${compile_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