Browse Source

fix(heroku): fix XDG cache directory name and code style (#10436)

smac89 2 years ago
parent
commit
b7fb0a55c0
1 changed files with 8 additions and 8 deletions
  1. 8 8
      plugins/heroku/heroku.plugin.zsh

+ 8 - 8
plugins/heroku/heroku.plugin.zsh

@@ -1,9 +1,9 @@
-HEROKU_AC_CACHE_DIR="$HOME/.cache"
-if [ "$(uname -s)" = "Darwin" ]; then
-  HEROKU_AC_CACHE_DIR="$HOME/Library/Caches"
+if [[ "$OSTYPE" = darwin* ]]; then
+  cache_dir="${HOME}/Library/Caches"
+else
+  cache_dir="${XDG_CACHE_HOME:-"${HOME}/.cache"}"
 fi
-if [ ! -z "$XDG_CACHE_HOME" ]; then
-  HEROKU_AC_CACHE_DIR="$XDG_CACHE_DIR"
-fi
-HEROKU_AC_ZSH_SETUP_PATH=$HEROKU_AC_CACHE_DIR/heroku/autocomplete/zsh_setup
-[ -f $HEROKU_AC_ZSH_SETUP_PATH ] && source $HEROKU_AC_ZSH_SETUP_PATH
+
+setup_path="${cache_dir}/heroku/autocomplete/zsh_setup"
+[[ -f "$setup_path" ]] && source $setup_path
+unset cache_dir setup_path