Skip to content
Myr

[New] add support for `$XDG_CONFIG_HOME`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Erik Lilja · committed by Jordan Harband · parent f218a85 · Browse files · 3 files+13 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+13 added−4 removed

  • tests:+3 added−2 removed
  • other:+10 added−2 removed

3 files+13 added−4 removed

modified:test/install_script/nvm_install_dir+3 added-2 removed
14 unmodified lines
15install_dir=$(nvm_install_dir)16[ "_$install_dir" = "_$NVM_DIR" ] || die "nvm_install_dir should use \$NVM_DIR if it exists. Current output: $install_dir"1718unset NVM_DIR1919# NVM_DIR is not set20install_dir=$(nvm_install_dir)22[ "_$install_dir" = "_$HOME/.nvm" ] || die "nvm_install_dir should default to \$HOME/.nvm. Current output: $install_dir"21fallback_dir=""22[ ! -z "$XDG_CONFIG_HOME" ] && fallback_dir="$XDG_CONFIG_HOME/nvm" || fallback_dir="$HOME/.nvm"23[ "_$install_dir" = "_$fallback_dir" ] || die "nvm_install_dir should default to \$XDG_CONFIG_DIR/.nvm. Current output: $install_dir"2425cleanup
modified:install.sh+7 added-1 removed
5 unmodified lines
6 type "$1" > /dev/null 2>&17}89nvm_install_dir() {10 command printf %s "${NVM_DIR:-"$HOME/.nvm"}"10 if [ ! -z "$NVM_DIR" ]; then11 printf %s "${NVM_DIR}"12 elif [ ! -z "$XDG_CONFIG_HOME" ]; then13 printf %s "${XDG_CONFIG_HOME/nvm}"14 else15 printf %s "$HOME/.nvm"16 fi17}1819nvm_latest_version() {20 echo "v0.33.11"
391 unmodified lines
modified:README.md+3 added-1 removed
52 unmodified lines
53```5455<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`).</sub>5657<sub>**Note:** If the environment variable `$XDG_CONFIG_HOME` is present, it will place the `nvm` files there.</sub>5859```sh58export NVM_DIR="$HOME/.nvm"60export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"61[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm62```6364**Note:** You can add `--no-use` to the end of the above script (...`nvm.sh --no-use`) to postpone using `nvm` until you manually [`use`](#usage) it.
527 unmodified lines