diff --git a/.changeset/yellow-otters-develop.md b/.changeset/yellow-otters-develop.md new file mode 100644 index 000000000..278264061 --- /dev/null +++ b/.changeset/yellow-otters-develop.md @@ -0,0 +1,5 @@ +--- +"fnm": patch +--- + +Make installation script respect `$XDG_DATA_HOME` diff --git a/.ci/install.sh b/.ci/install.sh index ebe39b3f5..1494da5f6 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -2,10 +2,19 @@ set -e -INSTALL_DIR="$HOME/.fnm" RELEASE="latest" OS="$(uname -s)" +if [ -d "$HOME/.fnm" ]; then + INSTALL_DIR="$HOME/.fnm" +elif [ -n "$XDG_DATA_HOME" ]; then + INSTALL_DIR="$XDG_DATA_HOME/fnm" +elif [ "$OS" = "Darwin" ]; then + INSTALL_DIR="$HOME/Library/Application Support/fnm" +else + INSTALL_DIR="$HOME/.local/share/fnm" +fi + # Parse Flags parse_args() { while [[ $# -gt 0 ]]; do @@ -154,12 +163,12 @@ setup_shell() { echo "Installing for Zsh. Appending the following to $CONF_FILE:" echo "" echo ' # fnm' - echo ' export PATH='"$INSTALL_DIR"':$PATH' + echo ' export PATH="'"$INSTALL_DIR"':$PATH"' echo ' eval "`fnm env`"' echo '' >>$CONF_FILE echo '# fnm' >>$CONF_FILE - echo 'export PATH='$INSTALL_DIR':$PATH' >>$CONF_FILE + echo 'export PATH="'$INSTALL_DIR':$PATH"' >>$CONF_FILE echo 'eval "`fnm env`"' >>$CONF_FILE elif [ "$CURRENT_SHELL" = "fish" ]; then @@ -168,11 +177,11 @@ setup_shell() { echo "Installing for Fish. Appending the following to $CONF_FILE:" echo "" echo ' # fnm' - echo ' set PATH '"$INSTALL_DIR"' $PATH' + echo ' set PATH "'"$INSTALL_DIR"'" $PATH' echo ' fnm env | source' echo '# fnm' >>$CONF_FILE - echo 'set PATH '"$INSTALL_DIR"' $PATH' >>$CONF_FILE + echo 'set PATH "'"$INSTALL_DIR"'" $PATH' >>$CONF_FILE echo 'fnm env | source' >>$CONF_FILE elif [ "$CURRENT_SHELL" = "bash" ]; then @@ -185,12 +194,12 @@ setup_shell() { echo "Installing for Bash. Appending the following to $CONF_FILE:" echo "" echo ' # fnm' - echo ' export PATH='"$INSTALL_DIR"':$PATH' + echo ' export PATH="'"$INSTALL_DIR"':$PATH"' echo ' eval "`fnm env`"' echo '' >>$CONF_FILE echo '# fnm' >>$CONF_FILE - echo 'export PATH='"$INSTALL_DIR"':$PATH' >>$CONF_FILE + echo 'export PATH="'"$INSTALL_DIR"':$PATH"' >>$CONF_FILE echo 'eval "`fnm env`"' >>$CONF_FILE else diff --git a/.github/workflows/installation_script.yml b/.github/workflows/installation_script.yml index b36a91af9..56440fb59 100644 --- a/.github/workflows/installation_script.yml +++ b/.github/workflows/installation_script.yml @@ -36,16 +36,16 @@ jobs: bash ./.ci/install.sh echo "fnm --version" - ~/.fnm/fnm --version + ~/.local/share/fnm/fnm --version echo "eval fnm env" - eval "$(~/.fnm/fnm env)" + eval "$(~/.local/share/fnm/fnm env)" echo "fnm install" - ~/.fnm/fnm install 12 + ~/.local/share/fnm/fnm install 12 echo "node -v" - ~/.fnm/fnm exec --using=12 -- node -v + ~/.local/share/fnm/fnm exec --using=12 -- node -v ' test_against_latest_release: