Skip to content

Instantly share code, notes, and snippets.

@Supernats
Created April 22, 2019 22:51
Show Gist options
  • Save Supernats/d2f89347df671945f44fac70c9a84371 to your computer and use it in GitHub Desktop.
Save Supernats/d2f89347df671945f44fac70c9a84371 to your computer and use it in GitHub Desktop.
#!/bin/sh
# update-gem
# Update gem in main appliation and all engines, if any.
#
# Notes:
# Must be run from root directory
# Must have postit installed, which makes sure Bundler versions defined in
# Gemfile.lock are respected.
# Takes one argument, the name of the gem
# example usage: `bin/update-gem rails`
set -euo pipefail
__gem_update__() {
GEM=$1
PROJECT_ROOT=$(git rev-parse --show-toplevel)
if [ $(pwd) != $PROJECT_ROOT ]
then
echo "Must be run from project root."
exit 1
fi
echo "Updating $1 in main application..."
postit update $GEM
printf "\n"
if [ ! -d "engines" ] || [ $(find ./engines/ -type d -d 1 | wc -l) -lt 1 ]
then
echo "No engines exist. Skipping engine gem updates."
exit 0
fi
for DIR in $(find ./engines -type d -d 1)
do
cd $DIR
echo "Updating $GEM in $(basename $PWD)..."
postit update $GEM
cd $PROJECT_ROOT
printf "\n"
done
echo "Done!"
exit 0
}
__gem_update__ $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment