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