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() { ...@@ -137,7 +137,7 @@ install_bins() {
mcount "version.iojs.$node_version" mcount "version.iojs.$node_version"
else else
warn_node_engine "$node_engine" 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 monitor "install-npm-binary" install_npm "$npm_engine" "$BUILD_DIR/.heroku/node" $NPM_LOCK
node_version="$(node --version)" node_version="$(node --version)"
mcount "version.node.$node_version" mcount "version.node.$node_version"
...@@ -147,7 +147,7 @@ install_bins() { ...@@ -147,7 +147,7 @@ install_bins() {
# has specified a version of yarn under "engines". We'll still # has specified a version of yarn under "engines". We'll still
# only install using yarn if there is a yarn.lock file # only install using yarn if there is a yarn.lock file
if $YARN || [ -n "$yarn_engine" ]; then 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 fi
if $YARN; then if $YARN; then
......
#!/usr/bin/env bash
install_yarn() { install_yarn() {
local dir="$1" local dir="$1"
local version=${2:-1.x} local version=${2:-1.x}
local number local platform="$3"
local url local number url code
echo "Resolving yarn version $version..." 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 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; fail_bin_install yarn "$version";
fi fi
echo "Downloading and installing yarn ($number)..." 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 if [ "$code" != "200" ]; then
echo "Unable to download yarn: $code" && false echo "Unable to download yarn: $code" && false
fi fi
rm -rf $dir rm -rf "$dir"
mkdir -p "$dir" mkdir -p "$dir"
# https://github.com/yarnpkg/yarn/issues/770 # https://github.com/yarnpkg/yarn/issues/770
if tar --version | grep -q 'gnu'; then if tar --version | grep -q 'gnu'; then
...@@ -22,54 +24,64 @@ install_yarn() { ...@@ -22,54 +24,64 @@ install_yarn() {
else else
tar xzf /tmp/yarn.tar.gz -C "$dir" --strip 1 tar xzf /tmp/yarn.tar.gz -C "$dir" --strip 1
fi fi
chmod +x $dir/bin/* chmod +x "$dir"/bin/*
echo "Installed yarn $(yarn --version)" echo "Installed yarn $(yarn --version)"
} }
install_nodejs() { install_nodejs() {
local version=${1:-10.x} local version=${1:-10.x}
local dir="${2:?}" local dir="${2:?}"
local platform="$3"
local code os cpu
os=$(get_os)
cpu=$(get_cpu)
echo "Resolving node version $version..." 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 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; fail_bin_install node "$version";
fi fi
echo "Downloading and installing node $number..." 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 if [ "$code" != "200" ]; then
echo "Unable to download node: $code" && 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$number-$os-$cpu/* $dir mv /tmp/node-v"$number"-"$os"-"$cpu"/* "$dir"
chmod +x $dir/bin/* chmod +x "$dir"/bin/*
} }
install_iojs() { install_iojs() {
local version="$1" local version="$1"
local dir="$2" local dir="$2"
local code os cpu
os=$(get_os)
cpu=$(get_cpu)
echo "Resolving iojs version ${version:-(latest stable)}..." 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 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; fail_bin_install iojs "$version";
fi fi
echo "Downloading and installing iojs $number..." 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 if [ "$code" != "200" ]; then
echo "Unable to download iojs: $code" && false echo "Unable to download iojs: $code" && false
fi fi
tar xzf /tmp/iojs.tar.gz -C /tmp tar xzf /tmp/iojs.tar.gz -C /tmp
mv /tmp/iojs-v$number-$os-$cpu/* $dir mv /tmp/iojs-v"$number"-"$os"-"$cpu"/* "$dir"
chmod +x $dir/bin/* chmod +x "$dir"/bin/*
} }
install_npm() { install_npm() {
local npm_version
local version="$1" local version="$1"
local dir="$2" local dir="$2"
local npm_lock="$3" 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 # 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 # 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 ...@@ -2,6 +2,7 @@ test: heroku-18 heroku-16 cedar-14
shellcheck: shellcheck:
@shellcheck -x bin/compile bin/detect bin/release bin/test bin/test-compile @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 lib/**/*.sh
@echo TODO shellcheck -x ci-profile/**/*.sh @echo TODO shellcheck -x ci-profile/**/*.sh
@echo TODO shellcheck -x etc/**/*.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