Skip to content

Instantly share code, notes, and snippets.

@oldfartdeveloper
Last active September 5, 2019 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oldfartdeveloper/7e2188a59efd93ee7f4e4d43fa9d826a to your computer and use it in GitHub Desktop.
Save oldfartdeveloper/7e2188a59efd93ee7f4e4d43fa9d826a to your computer and use it in GitHub Desktop.
A Bash script to switch between Elm 0.18 and 0.19
#!/usr/bin/env bash
#
# Switch between using different Elm family revisions; right now can switch between Elm 0.18.0 and Elm 0.19.0 revision
# "ecosystems". From the command line, invokde either
# elmswitch 18
# or
# elmswitch 19
#
# It is planned to add other revisions and patch revisions as desired.
#
# Assumptions:
#
# 1. Elm 0.18.0 version is found at /usr/local/bin/elm
# 2. Elm 0.19.0 version is found at ~/node-modules/elm
#
# elm-format and elm-live are also switched.
#
# Finally, when elm18 is selected, then in addition to elm-format and elm-live, the following elm aliases are available:
#
# elm-make
# elm-package
# elm-reactor
# elm-repl
remove_all () {
rm -f elm
rm -f elm-app
rm -f elm-format
rm -f elm-live
rm -f elm-make
rm -f elm-package
rm -f elm-reactor
rm -f elm-repl
}
case $1 in
"18" ) cd /usr/local/bin
remove_all
SUPERPATH="/usr/local//lib/node_modules"
ln -s $SUPERPATH/elm/binwrappers/elm elm
ln -s $SUPERPATH/create-elm-app/bin/elm-app-cli.js elm-app
ln -s $SUPERPATH/elm-live/bin/elm-live.js elm-live
ln -s $SUPERPATH/elm/binwrappers/elm-make elm-make
ln -s $SUPERPATH/elm/binwrappers/elm-package elm-package
ln -s $SUPERPATH/elm/binwrappers/elm-reactor elm-reactor
ln -s $SUPERPATH/elm/binwrappers/elm-repl elm-repl;;
"19" ) cd /usr/local/bin
remove_all
SUPERPATH="$HOME/node_modules"
ln -s $SUPERPATH/elm/bin/elm elm
ln -s $SUPERPATH/elm-format/bin/elm-format elm-format
ln -s $SUPERPATH/elm-live/bin/elm-live elm-live;;
*) echo "Value '$1' invalid; must be '18' or 19'"; exit 1;;
esac
echo "Switched to Elm 0.$1.0"
cd -
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment