Commit eff98f61 authored by Jeremy Morrell's avatar Jeremy Morrell Committed by GitHub

Check for .heroku/node (#384)

If a user pushes a source tree that already includes .heroku/node, give
a nice warning instead of a crypic error message.

Fixes #371
parent a055b999
...@@ -18,14 +18,6 @@ BUILD_DIR=${1:-} ...@@ -18,14 +18,6 @@ BUILD_DIR=${1:-}
CACHE_DIR=${2:-} CACHE_DIR=${2:-}
ENV_DIR=${3:-} ENV_DIR=${3:-}
BP_DIR=$(cd $(dirname ${0:-}); cd ..; pwd) BP_DIR=$(cd $(dirname ${0:-}); cd ..; pwd)
mkdir -p "$BUILD_DIR/.heroku/node/"
cd $BUILD_DIR
export PATH="$BUILD_DIR/.heroku/node/bin:$BUILD_DIR/.heroku/yarn/bin":$PATH
LOG_FILE=$(mktemp -t node-build-log.XXXXX)
echo "" > "$LOG_FILE"
STDLIB_FILE=$(mktemp -t stdlib.XXXXX) STDLIB_FILE=$(mktemp -t stdlib.XXXXX)
BUILDPACK_LOG_FILE=${BUILDPACK_LOG_FILE:-/dev/null} BUILDPACK_LOG_FILE=${BUILDPACK_LOG_FILE:-/dev/null}
...@@ -41,6 +33,11 @@ source $BP_DIR/lib/binaries.sh ...@@ -41,6 +33,11 @@ source $BP_DIR/lib/binaries.sh
source $BP_DIR/lib/cache.sh source $BP_DIR/lib/cache.sh
source $BP_DIR/lib/dependencies.sh source $BP_DIR/lib/dependencies.sh
export PATH="$BUILD_DIR/.heroku/node/bin:$BUILD_DIR/.heroku/yarn/bin":$PATH
LOG_FILE=$(mktemp -t node-build-log.XXXXX)
echo "" > "$LOG_FILE"
### Handle errors ### Handle errors
handle_failure() { handle_failure() {
...@@ -61,6 +58,8 @@ trap 'handle_failure' ERR ...@@ -61,6 +58,8 @@ trap 'handle_failure' ERR
### Failures that should be caught immediately ### Failures that should be caught immediately
fail_dot_heroku "$BUILD_DIR"
fail_dot_heroku_node "$BUILD_DIR"
fail_invalid_package_json "$BUILD_DIR" fail_invalid_package_json "$BUILD_DIR"
warn_prebuilt_modules "$BUILD_DIR" warn_prebuilt_modules "$BUILD_DIR"
warn_missing_package_json "$BUILD_DIR" warn_missing_package_json "$BUILD_DIR"
...@@ -75,6 +74,9 @@ create_env() { ...@@ -75,6 +74,9 @@ create_env() {
} }
header "Creating runtime environment" header "Creating runtime environment"
mkdir -p "$BUILD_DIR/.heroku/node/"
cd $BUILD_DIR
create_env # can't pipe the whole thing because piping causes subshells, preventing exports create_env # can't pipe the whole thing because piping causes subshells, preventing exports
list_node_config | output "$LOG_FILE" list_node_config | output "$LOG_FILE"
......
...@@ -35,6 +35,34 @@ fail_invalid_package_json() { ...@@ -35,6 +35,34 @@ fail_invalid_package_json() {
fi fi
} }
fail_dot_heroku() {
if [ -f "${1:-}/.heroku" ]; then
header "Build failed"
warn "The directory .heroku could not be created
It looks like a .heroku file is checked into this project.
The Node.js buildpack uses the hidden directory .heroku to store
binaries like the node runtime and npm. You should remove the
.heroku file or ignore it by adding it to .slugignore
"
exit 1
fi
}
fail_dot_heroku_node() {
if [ -f "${1:-}/.heroku/node" ]; then
header "Build failed"
warn "The directory .heroku/node could not be created
It looks like a .heroku file is checked into this project.
The Node.js buildpack uses the hidden directory .heroku to store
binaries like the node runtime and npm. You should remove the
.heroku file or ignore it by adding it to .slugignore
"
exit 1
fi
}
warning() { warning() {
local tip=${1:-} local tip=${1:-}
local url=${2:-https://devcenter.heroku.com/articles/nodejs-support} local url=${2:-https://devcenter.heroku.com/articles/nodejs-support}
......
This is is in .heroku/ but doesn't conflict with our files
{
"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": {},
"engines": {
"node": "0.10.29"
}
}
{
"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": {},
"engines": {
"node": "0.10.29"
}
}
{
"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": {},
"engines": {
"node": "0.10.29"
}
}
...@@ -184,6 +184,27 @@ testWarningsOnFailure() { ...@@ -184,6 +184,27 @@ testWarningsOnFailure() {
assertCapturedError assertCapturedError
} }
testDotHerokuCollision() {
compile "dot-heroku-collision"
assertCaptured "The directory .heroku could not be created"
assertCaptured ".heroku file is checked into this project"
assertNotCaptured "please submit a ticket"
assertCapturedError
compile "dot-heroku-collision-2"
assertCaptured "Build succeeded!"
assertNotCaptured ".heroku file is checked into this project"
assertCapturedSuccess
}
testDotHerokuNodeCollision() {
compile "dot-heroku-node-collision"
assertCaptured "The directory .heroku/node could not be created"
assertCaptured ".heroku file is checked into this project"
assertNotCaptured "please submit a ticket"
assertCapturedError
}
testMultipleRuns() { testMultipleRuns() {
local compileDir=$(mktmpdir) local compileDir=$(mktmpdir)
local cacheDir=$(mktmpdir) local cacheDir=$(mktmpdir)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment