Skip to content
Browse files

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

  • Loading branch information...
1 parent 26c18bc commit 36ad8a3bea11105c7cf150fcdda6cee004482927 @zeke zeke committed Jan 21, 2014
Showing with 23 additions and 9 deletions.
  1. +13 −0 bin/common.sh
  2. +4 −4 bin/compile
  3. +6 −5 bin/test
View
13 bin/common.sh
@@ -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
+}
View
8 bin/compile
@@ -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"
View
11 bin/test
@@ -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
}

0 comments on commit 36ad8a3

Please sign in to comment.
Something went wrong with that request. Please try again.