diff --git a/.ci/get_shell_profile.sh b/.ci/get_shell_profile.sh index 3da1bb2..7769b7f 100755 --- a/.ci/get_shell_profile.sh +++ b/.ci/get_shell_profile.sh @@ -1,16 +1,14 @@ #!/bin/bash -OS="$(uname -s)" - case $1 in "fish") - CONFIG_DIR="$(fish -c 'echo -n $__fish_config_dir')" - echo "${CONFIG_DIR-"$HOME/.config/fish"}/fish.config" + echo "$HOME/.config/fish/config.fish" ;; "zsh") echo "$HOME/.zshrc" ;; "bash") + OS="$(uname -s)" if [ "$OS" = "Darwin" ]; then echo "$HOME/.profile" else diff --git a/.ci/install.sh b/.ci/install.sh index 26b9c69..801f8c0 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -4,6 +4,7 @@ set -e INSTALL_DIR="$HOME/.fnm" RELEASE="latest" +OS="$(uname -s)" # Parse Flags parse_args() { @@ -39,10 +40,6 @@ parse_args() { } set_filename() { - local OS - - OS=$(uname -s) - if [ "$OS" == "Linux" ]; then FILENAME="fnm-linux" elif [ "$OS" == "Darwin" ] && [ "$FORCE_INSTALL" == "true" ]; then @@ -77,7 +74,7 @@ download_fnm() { mkdir -p "$INSTALL_DIR" &>/dev/null - if ! curl --progress-bar -L "$URL" -o "$DOWNLOAD_DIR/$FILENAME.zip"; then + if ! curl --progress-bar --fail -L "$URL" -o "$DOWNLOAD_DIR/$FILENAME.zip"; then echo "Download failed. Check that the release/filename are correct." exit 1 fi diff --git a/.ci/test_installation_script.sh b/.ci/test_installation_script.sh index 7311441..cee4b32 100755 --- a/.ci/test_installation_script.sh +++ b/.ci/test_installation_script.sh @@ -1,21 +1,37 @@ #!/bin/bash +set -e + DIRECTORY="$(dirname "$0")" SHELL_TO_RUN="$1" PROFILE_FILE="$("$DIRECTORY/get_shell_profile.sh" "$SHELL_TO_RUN")" +ls -lah ~ +echo "---" echo "Profile is $PROFILE_FILE" +echo "---" +cat "$PROFILE_FILE" +echo "---" +echo "PATH=$PATH" +echo "---" + +$SHELL_TO_RUN -c " + . $PROFILE_FILE + fnm --version +" -$SHELL_TO_RUN -c ' +$SHELL_TO_RUN -c " + . $PROFILE_FILE fnm install 12.5.0 fnm ls | grep 12.5.0 - echo "fnm ls worked." -' + echo 'fnm ls worked.' +" -$SHELL_TO_RUN -c ' +$SHELL_TO_RUN -c " + . $PROFILE_FILE fnm use 12.5.0 node --version | grep 12.5.0 - echo "node --version worked." -' + echo 'node --version worked.' +" diff --git a/.github/workflows/installation_script.yml b/.github/workflows/installation_script.yml index 210d2ad..a2517d5 100644 --- a/.github/workflows/installation_script.yml +++ b/.github/workflows/installation_script.yml @@ -31,8 +31,18 @@ jobs: - run: "brew install ${{ matrix.shell }}" name: Install ${{matrix.shell}} using Homebrew if: matrix.setup.os == 'macos' - - run: "cp ~/.bashrc ~/.bashrc.bak && echo '. ~/.bashrc.bak' > ~/.bashrc" - name: reset bashrc file + - run: | + if [ -f ~/.bashrc ]; then + cp ~/.bashrc ~/.bashrc.bak + echo 'echo hello world' > ~/.bashrc + echo '. ~/.bashrc.bak' >> ~/.bashrc + fi + + if [ -f ~/.zshrc ]; then + echo 'echo hello world' > ~/.zshrc + echo '. ~/.zshrc.bak' >> ~/.zshrc + fi + name: reset shell profiles - run: "env SHELL=$(which ${{ matrix.shell }}) bash ./.ci/install.sh ${{ matrix.setup.script_arguments }}" name: Run the installation script - run: ./.ci/test_installation_script.sh ${{ matrix.shell }}