Skip to content

Instantly share code, notes, and snippets.

@hhsnopek
Last active November 14, 2016 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hhsnopek/66ace53e120b0d203ff3e517aa94362e to your computer and use it in GitHub Desktop.
Save hhsnopek/66ace53e120b0d203ff3e517aa94362e to your computer and use it in GitHub Desktop.
Remove _cache for hardsource when using spike

Add this to your .bashrc...

This updates the spike call in a couple ways:

  1. if spike is found in the node_modules directory of the pwd, it will use that "local" version of spike rather than the global version
  2. adds spike clean all to remove _cache when that directory is present in pwd
# make your node_modules first class
spike() {
  local cmd

  # find command path
  if [[ -x ./node_modules/.bin/spike ]]; then
    cmd="./node_modules/.bin/spike"
  else
    cmd="spike"
  fi

  # additional operations dependent on param
  if [[ "$1" == "clean" ]]; then
    if [[ "$2" == "all" ]] && [[ -d ./_cache ]]; then
      rm -r _cache
      echo -e "\033[0;32m✓ cleaned cache\033[m "
    fi
    $cmd "clean"
  else
    $cmd "$@"
  fi

  return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment