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. 19
      .ci/install.sh

19
.ci/install.sh

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
set -e
INSTALL_DIR="$HOME/.fnm"
RELEASE="latest"
# Parse Flags
parse_args() {
@ -24,6 +25,11 @@ parse_args() { @@ -24,6 +25,11 @@ parse_args() {
FORCE_INSTALL="true"
shift
;;
-r | --release)
RELEASE="$2"
shift # past release argument
shift # past release value
;;
*)
echo "Unrecognized argument $key"
exit 1
@ -56,13 +62,24 @@ set_filename() { @@ -56,13 +62,24 @@ set_filename() {
}
download_fnm() {
URL=https://github.com/Schniz/fnm/releases/latest/download/$FILENAME.zip
if [ "$RELEASE" == "latest" ]; then
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)
echo "Downloading $URL..."
mkdir -p $INSTALL_DIR &>/dev/null
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
mv $DOWNLOAD_DIR/$FILENAME/fnm $INSTALL_DIR/fnm
chmod u+x $INSTALL_DIR/fnm

Loading…
Cancel
Save