Commit c56b58c8 authored by zeke's avatar zeke

experiment

parent 1e9b4890
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,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 -x # enable debugging # set -x # enable debugging
# Configure directories # Configure directories
build_dir=$1 build_dir=$1
...@@ -17,18 +17,6 @@ source $bp_dir/bin/common.sh ...@@ -17,18 +17,6 @@ source $bp_dir/bin/common.sh
# Output npm debug info on error # Output npm debug info on error
trap cat_npm_debug_log ERR 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 # 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) 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 ...@@ -81,9 +69,17 @@ elif test -d $cache_dir/node_modules; then
npm prune 2>&1 | indent npm prune 2>&1 | indent
fi fi
# Make npm output to STDOUT instead of its default STDERR # Scope config var availability only to `npm install`
status "Installing dependencies" (
npm install --userconfig $build_dir/.npmrc --production 2>&1 | indent 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" status "Caching node_modules directory for future builds"
rm -rf $cache_dir rm -rf $cache_dir
......
...@@ -104,6 +104,23 @@ testProcfileAbsentNpmStartAbsent() { ...@@ -104,6 +104,23 @@ testProcfileAbsentNpmStartAbsent() {
assertCapturedSuccess 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 # Pending Tests
# testNodeBinariesAddedToPath() { # testNodeBinariesAddedToPath() {
...@@ -132,6 +149,8 @@ testProcfileAbsentNpmStartAbsent() { ...@@ -132,6 +149,8 @@ testProcfileAbsentNpmStartAbsent() {
# assertCapturedError 1 "not found among available versions" # assertCapturedError 1 "not found among available versions"
# } # }
# Utils # Utils
pushd $(dirname 0) >/dev/null pushd $(dirname 0) >/dev/null
...@@ -159,6 +178,13 @@ compile() { ...@@ -159,6 +178,13 @@ compile() {
capture ${bp_dir}/bin/compile ${compile_dir} ${2:-$(mktmpdir)} 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() { assertFile() {
assertEquals "$1" "$(cat ${compile_dir}/$2)" 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