Skip to content

Commit

Permalink
fix: update.sh adds multiple lines to supports.sh #155 (#156)
Browse files Browse the repository at this point in the history
* fix: update.sh adds multiple lines to supports.sh #155

* chore: added comment

* chore: converted indentation to tabs
  • Loading branch information
bladerunner2020 committed Mar 18, 2024
1 parent 182d8e7 commit bf4189c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
21 changes: 19 additions & 2 deletions support.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ do_sed () {
fi
}

# Reverse the file from filename or stdin
do_tac () {
if [ "$(uname)" == "Darwin" ]; then # Mac
# macOS doesn't have tac, so we use tail -r
if (( $# == 0 )) ; then
tail -r < /dev/stdin
else
tail -r "$1"
fi
else # Linux
# linux doesn't have -r option for tail
if (( $# == 0 )) ; then
tac < /dev/stdin
else
tac "$1"
fi
fi
}


set_node_version() {
# Versions 1.9 through 2.2 need Node 12.22.1
Expand Down Expand Up @@ -61,9 +80,7 @@ set_node_version() {
elif [[ "$1" == 2.11.0 ]]; then node_version='14.21.3'
elif [[ "$1" == 2.12 ]]; then node_version='14.21.3'
elif [[ "$1" == 2.13 ]]; then node_version='14.21.4'
elif [[ "$1" == 2.14 ]]; then node_version='14.21.4'
elif [[ "$1" == 2.13.1 ]]; then node_version='14.21.4'
elif [[ "$1" == 2.14 ]]; then node_version='14.21.4'
elif [[ "$1" == 2.13.3 ]]; then node_version='14.21.4'
elif [[ "$1" == 2.14 ]]; then node_version='14.21.4'
fi # End of versions
Expand Down
11 changes: 10 additions & 1 deletion update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,16 @@ else

fi

do_sed $"s|'${node_version}'|'${node_version}'\\n elif [[ \"\$1\" == ${new_meteor_version} ]]; then node_version='${new_node_version}'|" ./support.sh

# Use cat here because the file is being written to in the same command
# Reverse the file, replace the first occurrence of the current node version with __XXXXXX__ as placeholder,
# reverse the file back, replace __XXXXXX__ back and add new line for the new Meteor version, and write the file back
cat ./support.sh \
| do_tac \
| sed "1,/'${node_version}'/s|'${node_version}'|'__XXXXXX__'|" \
| do_tac \
| sed "s|'__XXXXXX__'|'${node_version}'\\n elif [[ \"\$1\" == ${new_meteor_version} ]]; then node_version='${new_node_version}'|" \
| tee -i ./support.sh > /dev/null


# Update example app dependencies
Expand Down

0 comments on commit bf4189c

Please sign in to comment.