Skip to content

Commit c103ac6

Browse files
committed
chore: Simplify yarn and alpine version update
Before commit 3f6cb08 (fix: only update yarn if there are other changes to the dockerfile), yarnVersion depended on SKIP, so the substitute that followed made sense. This commit removed the condition and changed it to just substitute the version with itself, which doesn't make much sense. Just remove it, and also move the real replace inside SKIP condition. Also postpone retrieving the version to where it is used, and remove the initial assignment to alpine_version, which is never used.
1 parent e60f6a8 commit c103ac6

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

update.sh

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ fi
6565
# TODO: Should be able to specify target architecture manually
6666
arch=$(get_arch)
6767

68-
if [ "${SKIP}" != true ]; then
69-
alpine_version=$(get_config "./" "alpine_version")
70-
yarnVersion="$(curl -sSL --compressed https://yarnpkg.com/latest-version)"
71-
fi
72-
7368
function in_versions_to_update() {
7469
local version=$1
7570

@@ -135,9 +130,6 @@ function update_node_version() {
135130
sed -Ei -e 's/^FROM (.*)/FROM '"$fromprefix"'\1/' "${dockerfile}-tmp"
136131
sed -Ei -e 's/^(ENV NODE_VERSION ).*/\1'"${nodeVersion}"'/' "${dockerfile}-tmp"
137132

138-
currentYarnVersion="$(grep "ENV YARN_VERSION" "${dockerfile}" | cut -d' ' -f3)"
139-
sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${currentYarnVersion}"'/' "${dockerfile}-tmp"
140-
141133
# shellcheck disable=SC1004
142134
new_line=' \\\
143135
'
@@ -172,11 +164,10 @@ function update_node_version() {
172164
if diff -q "${dockerfile}-tmp" "${dockerfile}" > /dev/null; then
173165
echo "${dockerfile} is already up to date!"
174166
else
175-
if [ "${SKIP}" = true ]; then
176-
# Get the currently used Yarn version
177-
yarnVersion="$(grep "ENV YARN_VERSION" "${dockerfile}" | cut -d' ' -f3)"
167+
if [ "${SKIP}" != true ]; then
168+
yarnVersion="$(curl -sSL --compressed https://yarnpkg.com/latest-version)"
169+
sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${yarnVersion}"'/' "${dockerfile}-tmp"
178170
fi
179-
sed -Ei -e 's/^(ENV YARN_VERSION ).*/\1'"${yarnVersion}"'/' "${dockerfile}-tmp"
180171
echo "${dockerfile} updated!"
181172
fi
182173

0 commit comments

Comments
 (0)