diff --git a/bin/compile b/bin/compile index 855754aa7..87fd863ec 100755 --- a/bin/compile +++ b/bin/compile @@ -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 diff --git a/bin/test b/bin/test index a198ab58c..412deadb8 100755 --- a/bin/test +++ b/bin/test @@ -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() { diff --git a/test/procfile-absent-npm-start-absent/README.md b/test/procfile-absent-npm-start-absent/README.md new file mode 100644 index 000000000..cda334ae1 --- /dev/null +++ b/test/procfile-absent-npm-start-absent/README.md @@ -0,0 +1 @@ +A fake README, to keep npm from polluting stderr. \ No newline at end of file diff --git a/test/procfile-absent-npm-start-absent/package.json b/test/procfile-absent-npm-start-absent/package.json new file mode 100644 index 000000000..d5561df40 --- /dev/null +++ b/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" + } +} diff --git a/test/procfile-absent-npm-start-present/README.md b/test/procfile-absent-npm-start-present/README.md new file mode 100644 index 000000000..cda334ae1 --- /dev/null +++ b/test/procfile-absent-npm-start-present/README.md @@ -0,0 +1 @@ +A fake README, to keep npm from polluting stderr. \ No newline at end of file diff --git a/test/procfile-absent-npm-start-present/package.json b/test/procfile-absent-npm-start-present/package.json new file mode 100644 index 000000000..b8a6e9143 --- /dev/null +++ b/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" + } +}