#!/bin/zsh

### Compile bundles
#function __antidote_bundle_zcompile {
  emulate -L zsh; setopt local_options $_adote_funcopts
  builtin autoload -Uz zrecompile

  local -a bundles
  if [[ -z "$1" ]]; then
    bundles=($(antidote-list --dirs))
  elif [[ -f "$1" ]]; then
    zrecompile -pq "$1"
    return
  elif [[ -d "$1" ]]; then
    bundles=($1)
  else
    bundles=($(antidote-path "$1"))
  fi

  local bundle zfile
  for bundle in $bundles; do
    for zfile in ${bundle}/**/*.zsh{,-theme}(N); do
      [[ $zfile != */test-data/* ]] || continue
      zrecompile -pq "$zfile"
    done
  done
# }
