Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use bin/release instead of Procfile #231

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion bin/release
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#!/usr/bin/env bash
# bin/release <build-dir>
default_process_types() {
local bp_dir=$(cd $(dirname $0); cd ..; pwd)
local file="/tmp/default_process_types"
local result="default_process_types: {}"
if [ -f $file ]; then
result="default_process_types:\n $(cat $file)"
rm $file
fi
echo -e "$result"
}

cat << EOF
addons: []
default_process_types: {}
$(default_process_types)
EOF
8 changes: 4 additions & 4 deletions lib/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" > /tmp/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" > /tmp/default_process_types
else
info "None found"
fi
Expand Down
41 changes: 34 additions & 7 deletions test/run
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -262,28 +267,38 @@ testProcfileAbsentNpmStartAbsent() {
assertCaptured "None found"
assertNotCaptured "new Procfile"
assertCapturedSuccess
release "procfile-absent-npm-start-absent"
assertCaptured "default_process_types: {}"
assertCapturedSuccess
}

testDynamicProcfile() {
compile "dynamic-procfile"
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
}

Expand Down Expand Up @@ -464,12 +479,24 @@ detect() {

compile_dir=""

default_process_types_cleanup() {
file="/tmp/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)"
}
Expand Down