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

Commit 7335e6b

Browse files
authored
chore: remove code duplication in custom Node.js version logic (#757)
1 parent 195fbe1 commit 7335e6b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

run-build-functions.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ check_python_version() {
222222
fi
223223
}
224224

225+
read_node_version_file() {
226+
local nodeVersionFile="$1"
227+
NODE_VERSION="$(cat "$nodeVersionFile")"
228+
echo "Attempting node version '$NODE_VERSION' from $nodeVersionFile"
229+
}
230+
225231
install_dependencies() {
226232
local defaultNodeVersion=$1
227233
local defaultRubyVersion=$2
@@ -257,14 +263,12 @@ install_dependencies() {
257263
echo "Finished restoring cached node version"
258264
fi
259265

260-
if [ -f .nvmrc ]
266+
if [ -f ".nvmrc" ]
261267
then
262-
NODE_VERSION=$(cat .nvmrc)
263-
echo "Attempting node version '$NODE_VERSION' from .nvmrc"
264-
elif [ -f .node-version ]
268+
read_node_version_file ".nvmrc"
269+
elif [ -f ".node-version" ]
265270
then
266-
NODE_VERSION=$(cat .node-version)
267-
echo "Attempting node version '$NODE_VERSION' from .node-version"
271+
read_node_version_file ".node-version"
268272
fi
269273

270274
if nvm install --no-progress $NODE_VERSION

0 commit comments

Comments
 (0)