Browse Source

Specify the release to the install script (#176)

Github URLS are different between release/version so check during
download and install using the correct path.

Adding in a check for if the curl command fails to download.
remotes/origin/add-simple-redirecting-site
Chris Daley 5 years ago committed by Gal Schlezinger
parent
commit
145c92a86c
  1. 17
      .ci/install.sh

17
.ci/install.sh

@ -3,6 +3,7 @@
set -e set -e
INSTALL_DIR="$HOME/.fnm" INSTALL_DIR="$HOME/.fnm"
RELEASE="latest"
# Parse Flags # Parse Flags
parse_args() { parse_args() {
@ -24,6 +25,11 @@ parse_args() {
FORCE_INSTALL="true" FORCE_INSTALL="true"
shift shift
;; ;;
-r | --release)
RELEASE="$2"
shift # past release argument
shift # past release value
;;
*) *)
echo "Unrecognized argument $key" echo "Unrecognized argument $key"
exit 1 exit 1
@ -56,13 +62,24 @@ set_filename() {
} }
download_fnm() { download_fnm() {
if [ "$RELEASE" == "latest" ]; then
URL=https://github.com/Schniz/fnm/releases/latest/download/$FILENAME.zip URL=https://github.com/Schniz/fnm/releases/latest/download/$FILENAME.zip
else
URL=https://github.com/Schniz/fnm/releases/download/$RELEASE/$FILENAME.zip
fi
DOWNLOAD_DIR=$(mktemp -d) DOWNLOAD_DIR=$(mktemp -d)
echo "Downloading $URL..." echo "Downloading $URL..."
mkdir -p $INSTALL_DIR &>/dev/null mkdir -p $INSTALL_DIR &>/dev/null
curl --progress-bar -L $URL -o $DOWNLOAD_DIR/$FILENAME.zip curl --progress-bar -L $URL -o $DOWNLOAD_DIR/$FILENAME.zip
if [ 0 -ne $? ]; then
echo "Download failed. Check that the release/filename are correct."
exit 1
fi;
unzip -q $DOWNLOAD_DIR/$FILENAME.zip -d $DOWNLOAD_DIR unzip -q $DOWNLOAD_DIR/$FILENAME.zip -d $DOWNLOAD_DIR
mv $DOWNLOAD_DIR/$FILENAME/fnm $INSTALL_DIR/fnm mv $DOWNLOAD_DIR/$FILENAME/fnm $INSTALL_DIR/fnm
chmod u+x $INSTALL_DIR/fnm chmod u+x $INSTALL_DIR/fnm

Loading…
Cancel
Save