Commit 36ad8a3b authored by zeke's avatar zeke

update compile script to work with new buildpack-env-dir API

parent 26c18bce
......@@ -28,3 +28,16 @@ indent() {
cat_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
# Configure directories
build_dir=$1
cache_dir=$2
env_file=$3
env_dir=$3
bp_dir=$(cd $(dirname $0); cd ..; pwd)
......@@ -71,9 +71,9 @@ fi
# 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")
if [ -d "$env_dir" ]; then
status "Exporting config vars to environment"
export_env_dir $env_dir
fi
status "Installing dependencies"
......
......@@ -117,11 +117,12 @@ testEnvfileNotImported() {
assertCapturedSuccess
}
testEnvfileImported() {
env_file=$(mktemp)
echo "FOO=1" > $env_file
compile "stable-node" "$(mktmpdir)" $env_file
assertCaptured "Importing application config vars"
testEnvDirExported() {
env_dir=$(mktmpdir)
echo "chicken" > $env_dir/birds
echo "koi" > $env_dir/fish
compile "stable-node" "$(mktmpdir)" $env_dir
assertCaptured "Exporting config vars to environment"
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