Commit 9ec30558 authored by Jeremy Morrell's avatar Jeremy Morrell Committed by GitHub

Switch nodejs install over to using nodebin service (#451)

Switch nodejs install over to using nodebin
parent c0ecab66
...@@ -39,20 +39,19 @@ install_nodejs() { ...@@ -39,20 +39,19 @@ install_nodejs() {
local version=${1:-6.x} local version=${1:-6.x}
local dir="$2" local dir="$2"
if needs_resolution "$version"; then echo "Resolving node version $version..."
echo "Resolving node version $version via semver.io..." if ! read number url < <(curl --silent --get --retry 5 --retry-max-time 15 --data-urlencode "range=$version" "https://nodebin.herokai.com/v1/node/$platform/latest.txt"); then
local version=$(curl --silent --get --retry 5 --retry-max-time 15 --data-urlencode "range=${version}" https://semver.herokuapp.com/node/resolve) echo "Unable to resolve; does that version exist?" && false
fi fi
echo "Downloading and installing node $version..." echo "Downloading and installing node $number..."
local download_url="https://s3pository.heroku.com/node/v$version/node-v$version-$os-$cpu.tar.gz" local code=$(curl "$url" -L --silent --fail --retry 5 --retry-max-time 15 -o /tmp/node.tar.gz --write-out "%{http_code}")
local code=$(curl "$download_url" --silent --fail --retry 5 --retry-max-time 15 -o /tmp/node.tar.gz --write-out "%{http_code}")
if [ "$code" != "200" ]; then if [ "$code" != "200" ]; then
echo "Unable to download node $version; does it exist?" && false echo "Unable to download node: $code" && false
fi fi
tar xzf /tmp/node.tar.gz -C /tmp tar xzf /tmp/node.tar.gz -C /tmp
rm -rf $dir/* rm -rf $dir/*
mv /tmp/node-v$version-$os-$cpu/* $dir mv /tmp/node-v$number-$os-$cpu/* $dir
chmod +x $dir/bin/* chmod +x $dir/bin/*
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
testNoVersion() { testNoVersion() {
compile "no-version" compile "no-version"
assertCaptured "engines.node (package.json): unspecified" assertCaptured "engines.node (package.json): unspecified"
assertCaptured "Resolving node version 6.x via semver.io" assertCaptured "Resolving node version 6.x"
assertCaptured "Downloading and installing node 6." assertCaptured "Downloading and installing node 6."
assertCapturedSuccess assertCapturedSuccess
} }
...@@ -344,8 +344,8 @@ testConcurrencyCustomLimit() { ...@@ -344,8 +344,8 @@ testConcurrencyCustomLimit() {
testInvalidNode() { testInvalidNode() {
compile "invalid-node" compile "invalid-node"
assertCaptured "Downloading and installing node 0.11.333" assertCaptured "Resolving node version 0.11.333"
assertCaptured "Unable to download node 0.11.333" assertCaptured "Unable to resolve"
assertCapturedError assertCapturedError
} }
...@@ -405,7 +405,7 @@ testIoJs() { ...@@ -405,7 +405,7 @@ testIoJs() {
testSpecificVersion() { testSpecificVersion() {
compile "specific-version" compile "specific-version"
assertNotCaptured "Resolving node version" assertCaptured "Resolving node version"
assertCaptured "Downloading and installing node 0.10.29" assertCaptured "Downloading and installing node 0.10.29"
assertCaptured "Using default npm version: 1.4.14" assertCaptured "Using default npm version: 1.4.14"
assertCapturedSuccess assertCapturedSuccess
...@@ -420,7 +420,7 @@ testStableVersion() { ...@@ -420,7 +420,7 @@ testStableVersion() {
testUnstableVersion() { testUnstableVersion() {
compile "unstable-version" compile "unstable-version"
assertCaptured "Resolving node version 0.11.x via semver.io" assertCaptured "Resolving node version 0.11.x"
assertCaptured "Downloading and installing node 0.11." assertCaptured "Downloading and installing node 0.11."
assertCapturedSuccess assertCapturedSuccess
} }
...@@ -490,7 +490,7 @@ testInfoEmpty() { ...@@ -490,7 +490,7 @@ testInfoEmpty() {
testDangerousRangeStar() { testDangerousRangeStar() {
compile "dangerous-range-star" compile "dangerous-range-star"
assertCaptured "Dangerous semver range" assertCaptured "Dangerous semver range"
assertCaptured "Resolving node version * via semver.io" assertCaptured "Resolving node version *"
assertCaptured "Downloading and installing node 8." assertCaptured "Downloading and installing node 8."
assertCapturedError assertCapturedError
} }
...@@ -498,14 +498,14 @@ testDangerousRangeStar() { ...@@ -498,14 +498,14 @@ testDangerousRangeStar() {
testDangerousRangeGreaterThan() { testDangerousRangeGreaterThan() {
compile "dangerous-range-greater-than" compile "dangerous-range-greater-than"
assertCaptured "Dangerous semver range" assertCaptured "Dangerous semver range"
assertCaptured "Resolving node version >0.4 via semver.io" assertCaptured "Resolving node version >0.4"
assertCaptured "Downloading and installing node 8." assertCaptured "Downloading and installing node 8."
assertCapturedError assertCapturedError
} }
testRangeWithSpace() { testRangeWithSpace() {
compile "range-with-space" compile "range-with-space"
assertCaptured "Resolving node version >= 0.8.x via semver.io" assertCaptured "Resolving node version >= 0.8.x"
assertCaptured "Downloading and installing node 8." assertCaptured "Downloading and installing node 8."
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