Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update.sh adds multiple lines to supports.sh #155 #156

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't Linux have tail? So we could just use tail everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't Linux have tail? So we could just use tail everywhere?

There is no -r option on linux (checked on ubuntu):

root@fe890b91bb61:/# tail -r test.txt
tail: invalid option -- 'r'
Try 'tail --help' for more information.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that’s fine. Can you update the comment then to explain that macOS doesn’t have tac and Linux doesn’t have tail -r, hence the two approaches. Thanks for testing both.

Also please fix the whitespace on many of these lines; this repo uses tabs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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