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

Commit

Permalink
chore: remove code duplication in custom Node.js version logic (#757)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored Mar 24, 2022
1 parent 195fbe1 commit 7335e6b
Showing 1 changed file with 10 additions and 6 deletions.
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

0 comments on commit 7335e6b

Please sign in to comment.