Commit 5f0305ef authored by zeke's avatar zeke

simplify requested version detection, move node and npm binaries to /app/vendor

parent e1cfe21e
...@@ -8,12 +8,12 @@ set -e ...@@ -8,12 +8,12 @@ set -e
download_and_install_node() { download_and_install_node() {
version="$1" version="$1"
status "Downloading and installing node v$version"
node_url="http://s3pository.heroku.com/node/v$version/node-v$version-linux-x64.tar.gz" node_url="http://s3pository.heroku.com/node/v$version/node-v$version-linux-x64.tar.gz"
curl $node_url -s -o - | tar xzf - -C $build_dir curl $node_url -s -o - | tar xzf - -C $build_dir
mv $build_dir/node-v$version-linux-x64 $build_dir/node mkdir -p $build_dir/vendor
chmod +x $build_dir/node/bin/* mv $build_dir/node-v$version-linux-x64 $build_dir/vendor/node
PATH=$PATH:$build_dir/node/bin chmod +x $build_dir/vendor/node/bin/*
PATH=$PATH:$build_dir/vendor/node/bin
} }
query_stable_version() { query_stable_version() {
......
...@@ -12,15 +12,12 @@ source $bp_dir/bin/common.sh ...@@ -12,15 +12,12 @@ source $bp_dir/bin/common.sh
# Bootstrap the build process with latest stable version of node # Bootstrap the build process with latest stable version of node
# We'll use it to parse package.json and do semver detection # We'll use it to parse package.json and do semver detection
status "Bootstrapping node v$version"
download_and_install_node $stable_version download_and_install_node $stable_version
# Is a node version specified in package.json? # Is a node version specified in package.json?
determine_requested_version() { # https://github.com/trentm/json
# https://github.com/trentm/json requested_version=$(cat $build_dir/package.json | $bp_dir/vendor/json engines.node)
v=$(cat $build_dir/package.json | node $bp_dir/vendor/json engines.node 2>/dev/null)
if [ $? == 0 ]; then echo $v; fi
}
requested_version=$(determine_requested_version)
# Give a warning if engines.node is unspecified # Give a warning if engines.node is unspecified
if ! test $requested_version; then if ! test $requested_version; then
...@@ -52,6 +49,7 @@ else ...@@ -52,6 +49,7 @@ else
node_version=$(echo $evaluated_versions | tail -n 1) node_version=$(echo $evaluated_versions | tail -n 1)
if test $node_version; then if test $node_version; then
status "Downloading and installing node v$version"
download_and_install_node $node_version download_and_install_node $node_version
else else
error "node ${requested_version} not found among available versions on nodejs.org/dist" error "node ${requested_version} not found among available versions on nodejs.org/dist"
...@@ -92,4 +90,4 @@ fi ...@@ -92,4 +90,4 @@ fi
# Update the PATH # Update the PATH
status "Building runtime environment" status "Building runtime environment"
mkdir -p $build_dir/.profile.d mkdir -p $build_dir/.profile.d
echo "export PATH=\"\$HOME/node/bin:$HOME/bin:\$HOME/node_modules/.bin:\$PATH\"" > $build_dir/.profile.d/nodejs.sh echo "export PATH=\"\$HOME/vendor/node/bin:$HOME/bin:\$HOME/node_modules/.bin:\$PATH\"" > $build_dir/.profile.d/nodejs.sh
...@@ -47,7 +47,7 @@ testPackageJsonWithInvalidVersion() { ...@@ -47,7 +47,7 @@ testPackageJsonWithInvalidVersion() {
testProfileCreated() { testProfileCreated() {
compile "package-json-stable-version" compile "package-json-stable-version"
assertCaptured "Building runtime environment" assertCaptured "Building runtime environment"
assertFile "export PATH=\"\$HOME/node/bin:$HOME/bin:\$HOME/node_modules/.bin:\$PATH\"" ".profile.d/nodejs.sh" assertFile "export PATH=\"\$HOME/vendor/node/bin:$HOME/bin:\$HOME/node_modules/.bin:\$PATH\"" ".profile.d/nodejs.sh"
assertCapturedSuccess assertCapturedSuccess
} }
......
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