1
0

add fnm to yadm bootstrap

This commit is contained in:
2024-01-19 10:57:37 +01:00
parent 82688df171
commit e6bd010807

View File

@@ -0,0 +1,38 @@
#!/bin/bash
set -eu
source "${BOOTSTRAP_LIB}/helpers"
VERSION="1.35.1"
INSTALL_DIR="${HOME}/.local/bin"
INSTALLED_VERSION=""
if [[ -x "$(command -v fnm)" ]]; then
INSTALLED_VERSION="$(fnm --version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')"
fi
if [[ "$VERSION" == "$INSTALLED_VERSION" ]]; then
echo "fnm version ${VERSION} already installed."
exit 0
fi
echo "Installing fnm version ${VERSION}..."
URL="https://github.com/Schniz/fnm/releases/download/v${VERSION}/fnm-linux.zip"
echo "Downloading from ${URL}..."
TARGET="$(download "$URL")"
if [[ -f "${INSTALL_DIR}/fnm" ]]; then
echo "Removing old fnm command..."
rm -f "${INSTALL_DIR}/fnm"
fi
echo "Unpacking fnm command to ${INSTALL_DIR}..."
mkdir -p "${INSTALL_DIR}"
unzip "${TARGET}" fnm -d "${INSTALL_DIR}"
chmod +x "${INSTALL_DIR}/fnm"
echo "Removing ${TARGET}..."
rm -f "${TARGET}"