From 169b10b081274e5134b656b7bf9785790db0ded3 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Thu, 14 May 2015 19:20:01 -0500 Subject: [PATCH 1/2] use bin/release instead of Procfile --- bin/release | 13 ++++++++++++- lib/build.sh | 8 ++++---- test/run | 41 ++++++++++++++++++++++++++++++++++------- 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/bin/release b/bin/release index bc379507e..98e9ec350 100755 --- a/bin/release +++ b/bin/release @@ -1,6 +1,17 @@ #!/usr/bin/env bash # bin/release +default_process_types() { + local bp_dir=$(cd $(dirname $0); cd ..; pwd) + local file="$bp_dir/default_process_types" + local result="default_process_types: {}" + if [ -f $file ]; then + result="default_process_types:\n $(cat $bp_dir/default_process_types)" + rm $file + fi + echo -e "$result" +} + cat << EOF addons: [] -default_process_types: {} +$(default_process_types) EOF diff --git a/lib/build.sh b/lib/build.sh index e7bc8d579..776a9fb56 100644 --- a/lib/build.sh +++ b/lib/build.sh @@ -197,11 +197,11 @@ ensure_procfile() { elif test -f $build_dir/Procfile; then info "Procfile created during build" elif [ "$start_method" == "npm start" ]; then - info "No Procfile; Adding 'web: npm start' to new Procfile" - echo "web: npm start" > $build_dir/Procfile + info "No Procfile; Adding default process type 'web: npm start'" + echo "web: npm start" > $bp_dir/default_process_types elif [ "$start_method" == "server.js" ]; then - info "No Procfile; Adding 'web: node server.js' to new Procfile" - echo "web: node server.js" > $build_dir/Procfile + info "No Procfile; Adding default process type 'web: node server.js'" + echo "web: node server.js" > $bp_dir/default_process_types else info "None found" fi diff --git a/test/run b/test/run index 8c4af9dfc..f18373385 100755 --- a/test/run +++ b/test/run @@ -244,15 +244,20 @@ testUserConfig() { testProcfile() { compile "procfile-present-only" assertCaptured "Start mechanism: Procfile" - assertNotCaptured "new Procfile" + assertNotCaptured "Adding default process type" + assertCapturedSuccess + release "procfile-present-only" + assertCaptured "default_process_types: {}" assertCapturedSuccess } testProcfileAbsentNpmStartPresent() { compile "procfile-absent-npm-start-present" assertCaptured "Start mechanism: npm start" - assertCaptured "Adding 'web: npm start' to new Procfile" - assertFile "web: npm start" "Procfile" + assertCaptured "Adding default process type 'web: npm start'" + assertCapturedSuccess + release "procfile-absent-npm-start-present" + assertCaptured "web: npm start" assertCapturedSuccess } @@ -262,6 +267,9 @@ testProcfileAbsentNpmStartAbsent() { assertCaptured "None found" assertNotCaptured "new Procfile" assertCapturedSuccess + release "procfile-absent-npm-start-absent" + assertCaptured "default_process_types: {}" + assertCapturedSuccess } testDynamicProcfile() { @@ -269,21 +277,28 @@ testDynamicProcfile() { assertCaptured "Procfile created during build" assertFileContains "web: node index.js customArg" "${compile_dir}/Procfile" assertCapturedSuccess + release "dynamic-procfile" + assertCaptured "default_process_types: {}" + assertCapturedSuccess } testProcfileAbsentServerPresent() { compile "procfile-absent-server-present" assertCaptured "Start mechanism: server.js" - assertCaptured "'web: node server.js' to new Procfile" - assertFile "web: node server.js" "Procfile" + assertCaptured "Adding default process type 'web: node server.js'" + assertCapturedSuccess + release "procfile-absent-server-present" + assertCaptured "web: node server.js" assertCapturedSuccess } testServerPresentOnly() { compile "server-present-only" assertCaptured "Skipping dependencies" - assertCaptured "'web: node server.js' to new Procfile" - assertFile "web: node server.js" "Procfile" + assertCaptured "Adding default process type 'web: node server.js'" + assertCapturedSuccess + release "server-present-only" + assertCaptured "web: node server.js" assertCapturedSuccess } @@ -464,12 +479,24 @@ detect() { compile_dir="" +default_process_types_cleanup() { + file="${bp_dir}/default_process_types" + if [ -f "$file" ]; then + rm "$file" + fi +} + compile() { + default_process_types_cleanup compile_dir=$(mktmpdir) cp -r ${bp_dir}/test/fixtures/$1/. ${compile_dir} capture ${bp_dir}/bin/compile ${compile_dir} ${2:-$(mktmpdir)} $3 } +release() { + capture ${bp_dir}/bin/release ${bp_dir}/test/fixtures/$1 +} + assertFile() { assertEquals "$1" "$(cat ${compile_dir}/$2)" } From b72c9e5065ed3b35b46ba92b78431020af64ac0b Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Fri, 15 May 2015 13:40:55 -0500 Subject: [PATCH 2/2] save default_process_types file to /tmp/ instead of the buildpack directory --- bin/release | 4 ++-- lib/build.sh | 4 ++-- test/run | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/release b/bin/release index 98e9ec350..5983663a0 100755 --- a/bin/release +++ b/bin/release @@ -2,10 +2,10 @@ # bin/release default_process_types() { local bp_dir=$(cd $(dirname $0); cd ..; pwd) - local file="$bp_dir/default_process_types" + local file="/tmp/default_process_types" local result="default_process_types: {}" if [ -f $file ]; then - result="default_process_types:\n $(cat $bp_dir/default_process_types)" + result="default_process_types:\n $(cat $file)" rm $file fi echo -e "$result" diff --git a/lib/build.sh b/lib/build.sh index 776a9fb56..22cd86913 100644 --- a/lib/build.sh +++ b/lib/build.sh @@ -198,10 +198,10 @@ ensure_procfile() { info "Procfile created during build" elif [ "$start_method" == "npm start" ]; then info "No Procfile; Adding default process type 'web: npm start'" - echo "web: npm start" > $bp_dir/default_process_types + echo "web: npm start" > /tmp/default_process_types elif [ "$start_method" == "server.js" ]; then info "No Procfile; Adding default process type 'web: node server.js'" - echo "web: node server.js" > $bp_dir/default_process_types + echo "web: node server.js" > /tmp/default_process_types else info "None found" fi diff --git a/test/run b/test/run index f18373385..58f492e10 100755 --- a/test/run +++ b/test/run @@ -480,7 +480,7 @@ detect() { compile_dir="" default_process_types_cleanup() { - file="${bp_dir}/default_process_types" + file="/tmp/default_process_types" if [ -f "$file" ]; then rm "$file" fi