Unverified Commit e2a1b61c authored by Jeremy Morrell's avatar Jeremy Morrell Committed by GitHub

Add lib/binaries.sh to shellcheck (#604)

* Make lib/binaries.sh pass shellcheck
parent f785c74e
......@@ -137,7 +137,7 @@ install_bins() {
mcount "version.iojs.$node_version"
else
warn_node_engine "$node_engine"
monitor "install-node-binary" install_nodejs "$node_engine" "$BUILD_DIR/.heroku/node"
monitor "install-node-binary" install_nodejs "$node_engine" "$BUILD_DIR/.heroku/node" "$platform"
monitor "install-npm-binary" install_npm "$npm_engine" "$BUILD_DIR/.heroku/node" $NPM_LOCK
node_version="$(node --version)"
mcount "version.node.$node_version"
......@@ -147,7 +147,7 @@ install_bins() {
# has specified a version of yarn under "engines". We'll still
# only install using yarn if there is a yarn.lock file
if $YARN || [ -n "$yarn_engine" ]; then
monitor "install-yarn-binary" install_yarn "$BUILD_DIR/.heroku/yarn" "$yarn_engine"
monitor "install-yarn-binary" install_yarn "$BUILD_DIR/.heroku/yarn" "$yarn_engine" "$platform"
fi
if $YARN; then
......
#!/usr/bin/env bash
install_yarn() {
local dir="$1"
local version=${2:-1.x}
local number
local url
local platform="$3"
local number url code
echo "Resolving yarn version $version..."
if ! read number url < <(curl --silent --get --retry 5 --retry-max-time 15 --data-urlencode "range=$version" "https://nodebin.herokai.com/v1/yarn/$platform/latest.txt"); then
fail_bin_install yarn $version;
if ! read -r number url < <(curl --silent --get --retry 5 --retry-max-time 15 --data-urlencode "range=$version" "https://nodebin.herokai.com/v1/yarn/$platform/latest.txt"); then
fail_bin_install yarn "$version";
fi
echo "Downloading and installing yarn ($number)..."
local code=$(curl "$url" -L --silent --fail --retry 5 --retry-max-time 15 -o /tmp/yarn.tar.gz --write-out "%{http_code}")
code=$(curl "$url" -L --silent --fail --retry 5 --retry-max-time 15 -o /tmp/yarn.tar.gz --write-out "%{http_code}")
if [ "$code" != "200" ]; then
echo "Unable to download yarn: $code" && false
fi
rm -rf $dir
rm -rf "$dir"
mkdir -p "$dir"
# https://github.com/yarnpkg/yarn/issues/770
if tar --version | grep -q 'gnu'; then
......@@ -22,54 +24,64 @@ install_yarn() {
else
tar xzf /tmp/yarn.tar.gz -C "$dir" --strip 1
fi
chmod +x $dir/bin/*
chmod +x "$dir"/bin/*
echo "Installed yarn $(yarn --version)"
}
install_nodejs() {
local version=${1:-10.x}
local dir="${2:?}"
local platform="$3"
local code os cpu
os=$(get_os)
cpu=$(get_cpu)
echo "Resolving node version $version..."
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
fail_bin_install node $version;
if ! read -r 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
fail_bin_install node "$version";
fi
echo "Downloading and installing node $number..."
local code=$(curl "$url" -L --silent --fail --retry 5 --retry-max-time 15 -o /tmp/node.tar.gz --write-out "%{http_code}")
code=$(curl "$url" -L --silent --fail --retry 5 --retry-max-time 15 -o /tmp/node.tar.gz --write-out "%{http_code}")
if [ "$code" != "200" ]; then
echo "Unable to download node: $code" && false
fi
tar xzf /tmp/node.tar.gz -C /tmp
rm -rf "$dir"/*
mv /tmp/node-v$number-$os-$cpu/* $dir
chmod +x $dir/bin/*
rm -rf "${dir:?}"/*
mv /tmp/node-v"$number"-"$os"-"$cpu"/* "$dir"
chmod +x "$dir"/bin/*
}
install_iojs() {
local version="$1"
local dir="$2"
local code os cpu
os=$(get_os)
cpu=$(get_cpu)
echo "Resolving iojs version ${version:-(latest stable)}..."
if ! read number url < <(curl --silent --get --retry 5 --retry-max-time 15 --data-urlencode "range=$version" "https://nodebin.herokai.com/v1/iojs/$platform/latest.txt"); then
fail_bin_install iojs $version;
if ! read -r number url < <(curl --silent --get --retry 5 --retry-max-time 15 --data-urlencode "range=$version" "https://nodebin.herokai.com/v1/iojs/$platform/latest.txt"); then
fail_bin_install iojs "$version";
fi
echo "Downloading and installing iojs $number..."
local code=$(curl "$url" --silent --fail --retry 5 --retry-max-time 15 -o /tmp/iojs.tar.gz --write-out "%{http_code}")
code=$(curl "$url" --silent --fail --retry 5 --retry-max-time 15 -o /tmp/iojs.tar.gz --write-out "%{http_code}")
if [ "$code" != "200" ]; then
echo "Unable to download iojs: $code" && false
fi
tar xzf /tmp/iojs.tar.gz -C /tmp
mv /tmp/iojs-v$number-$os-$cpu/* $dir
chmod +x $dir/bin/*
mv /tmp/iojs-v"$number"-"$os"-"$cpu"/* "$dir"
chmod +x "$dir"/bin/*
}
install_npm() {
local npm_version
local version="$1"
local dir="$2"
local npm_lock="$3"
local npm_version="$(npm --version)"
npm_version="$(npm --version)"
# If the user has not specified a version of npm, but has an npm lockfile
# upgrade them to npm 5.x if a suitable version was not installed with Node
......
......@@ -2,6 +2,7 @@ test: heroku-18 heroku-16 cedar-14
shellcheck:
@shellcheck -x bin/compile bin/detect bin/release bin/test bin/test-compile
@shellcheck -x lib/binaries.sh
@echo TODO shellcheck -x lib/**/*.sh
@echo TODO shellcheck -x ci-profile/**/*.sh
@echo TODO shellcheck -x etc/**/*.sh
......
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