Commit d2ca0c2c authored by Zeke Sikelianos's avatar Zeke Sikelianos

Merge pull request #94 from heroku/clever-ponies-um

update compile script to work with new buildpack-env-dir API
parents 26c18bce 9e1e554b
...@@ -28,3 +28,16 @@ indent() { ...@@ -28,3 +28,16 @@ indent() {
cat_npm_debug_log() { cat_npm_debug_log() {
test -f $build_dir/npm-debug.log && cat $build_dir/npm-debug.log test -f $build_dir/npm-debug.log && cat $build_dir/npm-debug.log
} }
export_env_dir() {
env_dir=$1
whitelist_regex=${2:-''}
blacklist_regex=${3:-'^(PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH)$'}
if [ -d "$env_dir" ]; then
for e in $(ls $env_dir); do
echo "$e" | grep -E "$whitelist_regex" | grep -qvE "$blacklist_regex" &&
export "$e=$(cat $env_dir/$e)"
:
done
fi
}
...@@ -7,7 +7,7 @@ set -o pipefail # don't ignore exit codes when piping output ...@@ -7,7 +7,7 @@ set -o pipefail # don't ignore exit codes when piping output
# Configure directories # Configure directories
build_dir=$1 build_dir=$1
cache_dir=$2 cache_dir=$2
env_file=$3 env_dir=$3
bp_dir=$(cd $(dirname $0); cd ..; pwd) bp_dir=$(cd $(dirname $0); cd ..; pwd)
...@@ -71,9 +71,9 @@ fi ...@@ -71,9 +71,9 @@ fi
# Scope config var availability only to `npm install` # Scope config var availability only to `npm install`
( (
if [ "$env_file" ]; then if [ -d "$env_dir" ]; then
status "Importing application config vars" status "Exporting config vars to environment"
export $(egrep -v "^(PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH)" "$env_file") export_env_dir $env_dir
fi fi
status "Installing dependencies" status "Installing dependencies"
......
...@@ -111,17 +111,18 @@ testProcfileAbsentNpmStartPresent() { ...@@ -111,17 +111,18 @@ testProcfileAbsentNpmStartPresent() {
assertCapturedSuccess assertCapturedSuccess
} }
testEnvfileNotImported() { testEnvDirNotImported() {
compile "stable-node" compile "stable-node"
assertNotCaptured "Importing application config vars" assertNotCaptured "Exporting config vars to environment"
assertCapturedSuccess assertCapturedSuccess
} }
testEnvfileImported() { testEnvDirExported() {
env_file=$(mktemp) env_dir=$(mktmpdir)
echo "FOO=1" > $env_file echo "chicken" > $env_dir/birds
compile "stable-node" "$(mktmpdir)" $env_file echo "koi" > $env_dir/fish
assertCaptured "Importing application config vars" compile "stable-node" "$(mktmpdir)" $env_dir
assertCaptured "Exporting config vars to environment"
assertCapturedSuccess assertCapturedSuccess
} }
......
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