Skip to content

Commit

Permalink
add tests around creating a default Procfile
Browse files Browse the repository at this point in the history
  • Loading branch information
zeke committed Dec 11, 2013
1 parent d93ee4c commit e9266df
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bin/compile
Expand Up @@ -80,14 +80,15 @@ status "Cleaning up node-gyp and npm artifacts"
rm -rf "$build_dir/.node-gyp"
rm -rf "$build_dir/.npm"

# Add npm start to Procfile if necessary
# If Procfile is absent, try to create one using `npm start`
if [ ! -e $build_dir/Procfile ]; then
npm_start=$(cat $build_dir/package.json | $bp_dir/vendor/jq -r .scripts.start)

# If a start script is declared, add it to a Procfile
if [ "$npm_start" != "null" ]; then
status "No Procfile present; adding npm start script to Procfile"
echo "web: $npm_start" > $build_dir/Procfile
if [ "$npm_start" == "null" ]; then
protip "Create a Procfile or specify a start script in package.json"
else
status "No Procfile found; adding npm start script to Procfile"
echo "web: npm start" > $build_dir/Procfile
fi
fi

Expand Down
13 changes: 13 additions & 0 deletions bin/test
Expand Up @@ -91,6 +91,19 @@ testUserConfig() {
assertCapturedError 1 ""
}

testProcfileAbsentNpmStartPresent() {
compile "procfile-absent-npm-start-present"
assertCaptured "No Procfile found; adding npm start script to Procfile"
assertFile "web: npm start" "Procfile"
assertCapturedSuccess
}

testProcfileAbsentNpmStartAbsent() {
compile "procfile-absent-npm-start-absent"
assertCaptured "Create a Procfile or specify a start script"
assertCapturedSuccess
}

# Pending Tests

# testNodeBinariesAddedToPath() {
Expand Down
1 change: 1 addition & 0 deletions test/procfile-absent-npm-start-absent/README.md
@@ -0,0 +1 @@
A fake README, to keep npm from polluting stderr.
15 changes: 15 additions & 0 deletions test/procfile-absent-npm-start-absent/package.json
@@ -0,0 +1,15 @@
{
"name": "node-buildpack-test-app",
"version": "0.0.1",
"description": "node buildpack integration test app",
"repository" : {
"type" : "git",
"url" : "http://github.com/example/example.git"
},
"dependencies": {
"hashish": "*"
},
"engines": {
"node": "~0.10.0"
}
}
1 change: 1 addition & 0 deletions test/procfile-absent-npm-start-present/README.md
@@ -0,0 +1 @@
A fake README, to keep npm from polluting stderr.
18 changes: 18 additions & 0 deletions test/procfile-absent-npm-start-present/package.json
@@ -0,0 +1,18 @@
{
"name": "node-buildpack-test-app",
"version": "0.0.1",
"description": "node buildpack integration test app",
"repository" : {
"type" : "git",
"url" : "http://github.com/example/example.git"
},
"dependencies": {
"hashish": "*"
},
"engines": {
"node": "~0.10.0"
},
"scripts": {
"start": "echo foo"
}
}

0 comments on commit e9266df

Please sign in to comment.