From f5f0bcb3cdef1458448eb54103a624bef549e556 Mon Sep 17 00:00:00 2001 From: Gal Schlezinger Date: Mon, 22 Jul 2019 13:42:30 +0300 Subject: [PATCH] =?UTF-8?q?Deprecates=20MacOS=20installation=20using=20the?= =?UTF-8?q?=20script=20in=20favor=20of=20Homeb=E2=80=A6=20(#131)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Deprecates MacOS installation using the script in favor of Homebrew * Add the warning in the script --- .ci/install.sh | 41 +++++++++++++++++++++++++++++------------ README.md | 6 +++++- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/.ci/install.sh b/.ci/install.sh index aefee99..4069fc7 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -2,18 +2,6 @@ set -e -OS=$(uname -s) - -if [ "$OS" == "Darwin" ]; then - FILENAME="fnm-macos" -elif [ "$OS" == "Linux" ]; then - FILENAME="fnm-linux" -else - echo "OS $OS is not supported." - echo "If you think that's a bug - please file an issue to https://github.com/Schniz/fnm/issues" - exit 1 -fi - INSTALL_DIR="$HOME/.fnm" # Parse Flags @@ -31,6 +19,11 @@ parse_args() { SKIP_SHELL="true" shift # past argument ;; + --force-install) + echo "\`--force-install\`: I hope you know what you're doing." >&2 + FORCE_INSTALL="true" + shift + ;; *) echo "Unrecognized argument $key" exit 1 @@ -39,6 +32,29 @@ parse_args() { done } +set_filename() { + local OS + + OS=$(uname -s) + + if [ "$OS" == "Linux" ]; then + FILENAME="fnm-linux" + elif [ "$OS" == "Darwin" ] && [ "$FORCE_INSTALL" == "true" ]; then + FILENAME="fnm-macos" + elif [ "$OS" == "Darwin" ]; then + echo "Hey! Thanks for trying fnm." + echo "MacOS installation works better using Homebrew." + echo "Please consider installing using:" + echo " $ brew install Schniz/tap/fnm" + echo "or run the script again with the \`--force-install\` option." + exit 1 + else + echo "OS $OS is not supported." + echo "If you think that's a bug - please file an issue to https://github.com/Schniz/fnm/issues" + exit 1 + fi +} + download_fnm() { URL=https://github.com/Schniz/fnm/releases/latest/download/$FILENAME.zip DOWNLOAD_DIR=$(mktemp -d) @@ -134,6 +150,7 @@ setup_shell() { } parse_args "$@" +set_filename check_dependencies download_fnm if [ "$SKIP_SHELL" != "true" ]; then diff --git a/README.md b/README.md index ffb4142..44bf09c 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ For `bash`, `zsh` and `fish` shells, there's an [automatic installation script]( curl -fsSL https://github.com/Schniz/fnm/raw/master/.ci/install.sh | bash ``` -### Upgrade +### Upgrade Upgrading `fnm` is almost the same as installing it. To prevent duplication in your shell config file add `--skip-shell` to install command. @@ -50,6 +50,10 @@ Set a custom directory for fnm to be installed. The default is `$HOME/.fnm`. Skip appending shell specific loader to shell config file, based on the current user shell, defined in `$SHELL`. e.g. for Bash, `$HOME/.bashrc`. `$HOME/.zshrc` for Zsh. For Fish - `$HOME/.config/fish/config.fish` +`--force-install` + +MacOS installations using the installation script are deprecated in favor of the Homebrew formula, but this forces the script to install using it anyway. + Example: ```bash