From 6f1db155fc5bb61c36619ef5347446fa167888d4 Mon Sep 17 00:00:00 2001 From: jonz94 Date: Tue, 28 Dec 2021 22:05:12 +0800 Subject: [PATCH 1/6] Make installation script respect $XDG_DATA_HOME --- .ci/install.sh | 7 ++++++- .github/workflows/installation_script.yml | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.ci/install.sh b/.ci/install.sh index ebe39b3f5..01ac519e2 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -2,7 +2,12 @@ set -e -INSTALL_DIR="$HOME/.fnm" +if [ -d "$HOME/.fnm" ]; then + INSTALL_DIR="$HOME/.fnm" +else + INSTALL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/fnm" +fi + RELEASE="latest" OS="$(uname -s)" diff --git a/.github/workflows/installation_script.yml b/.github/workflows/installation_script.yml index a079e2539..a1c099978 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: From 551da75f01835c8c1a92939447bd1959bec82a91 Mon Sep 17 00:00:00 2001 From: jonz94 Date: Thu, 30 Dec 2021 03:29:29 +0800 Subject: [PATCH 2/6] Add os check to determine INSTALL_DIR default location --- .ci/install.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.ci/install.sh b/.ci/install.sh index 01ac519e2..dd1091f2c 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -2,15 +2,17 @@ set -e +RELEASE="latest" +OS="$(uname -s)" + if [ -d "$HOME/.fnm" ]; then INSTALL_DIR="$HOME/.fnm" +elif [ "$OS" = "Darwin" ]; then + INSTALL_DIR="${XDG_DATA_HOME:-$HOME/Library/Application\ Support}/fnm" else INSTALL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/fnm" fi -RELEASE="latest" -OS="$(uname -s)" - # Parse Flags parse_args() { while [[ $# -gt 0 ]]; do From 1ae5ab98d45b0128bcebf1a2cff83c758e58d1de Mon Sep 17 00:00:00 2001 From: jonz94 Date: Thu, 30 Dec 2021 03:47:02 +0800 Subject: [PATCH 3/6] Minor refactor --- .ci/install.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.ci/install.sh b/.ci/install.sh index dd1091f2c..90c1346aa 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -7,10 +7,12 @@ OS="$(uname -s)" if [ -d "$HOME/.fnm" ]; then INSTALL_DIR="$HOME/.fnm" +elif [ ! -z $XDG_DATA_HOME ]; then + INSTALL_DIR="$XDG_DATA_HOME/fnm" elif [ "$OS" = "Darwin" ]; then - INSTALL_DIR="${XDG_DATA_HOME:-$HOME/Library/Application\ Support}/fnm" + INSTALL_DIR="$HOME/Library/Application\ Support/fnm" else - INSTALL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/fnm" + INSTALL_DIR="$HOME/.local/share/fnm" fi # Parse Flags From 24aa4e336b7517576d94c2085e9653d4589cd0f3 Mon Sep 17 00:00:00 2001 From: jonz94 Date: Tue, 4 Jan 2022 12:24:49 +0800 Subject: [PATCH 4/6] Use `test -n` with double quotes --- .ci/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/install.sh b/.ci/install.sh index 90c1346aa..167240387 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -7,7 +7,7 @@ OS="$(uname -s)" if [ -d "$HOME/.fnm" ]; then INSTALL_DIR="$HOME/.fnm" -elif [ ! -z $XDG_DATA_HOME ]; then +elif [ -n "$XDG_DATA_HOME" ]; then INSTALL_DIR="$XDG_DATA_HOME/fnm" elif [ "$OS" = "Darwin" ]; then INSTALL_DIR="$HOME/Library/Application\ Support/fnm" From 9ceb18e7aeaea7fe87f96a10fd3e1b3f5df05d7c Mon Sep 17 00:00:00 2001 From: jonz94 Date: Wed, 5 Jan 2022 08:22:52 +0800 Subject: [PATCH 5/6] Fix space in directory name issue --- .ci/install.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.ci/install.sh b/.ci/install.sh index 167240387..1494da5f6 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -10,7 +10,7 @@ if [ -d "$HOME/.fnm" ]; then elif [ -n "$XDG_DATA_HOME" ]; then INSTALL_DIR="$XDG_DATA_HOME/fnm" elif [ "$OS" = "Darwin" ]; then - INSTALL_DIR="$HOME/Library/Application\ Support/fnm" + INSTALL_DIR="$HOME/Library/Application Support/fnm" else INSTALL_DIR="$HOME/.local/share/fnm" fi @@ -163,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 @@ -177,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 @@ -194,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 From 8c05fa0d3bf18faa9b4c64cdeeb46c22befa5328 Mon Sep 17 00:00:00 2001 From: Gal Schlezinger Date: Thu, 17 Nov 2022 17:11:26 +0200 Subject: [PATCH 6/6] Create yellow-otters-develop.md --- .changeset/yellow-otters-develop.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/yellow-otters-develop.md 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`