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