Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

chore: remove code duplication in custom Node.js version logic #757

Merged
merged 2 commits into from
Mar 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions run-build-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ check_python_version() {
fi
}

read_node_version_file() {
local nodeVersionFile="$1"
NODE_VERSION="$(cat "$nodeVersionFile")"
echo "Attempting node version '$NODE_VERSION' from $nodeVersionFile"
}

install_dependencies() {
local defaultNodeVersion=$1
local defaultRubyVersion=$2
Expand Down Expand Up @@ -257,14 +263,12 @@ install_dependencies() {
echo "Finished restoring cached node version"
fi

if [ -f .nvmrc ]
if [ -f ".nvmrc" ]
then
NODE_VERSION=$(cat .nvmrc)
echo "Attempting node version '$NODE_VERSION' from .nvmrc"
elif [ -f .node-version ]
read_node_version_file ".nvmrc"
elif [ -f ".node-version" ]
then
NODE_VERSION=$(cat .node-version)
echo "Attempting node version '$NODE_VERSION' from .node-version"
read_node_version_file ".node-version"
fi

if nvm install --no-progress $NODE_VERSION
Expand Down