Skip to content

Commit

Permalink
WIP: bundle compile feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmc3 committed Nov 29, 2023
1 parent 0b80ba4 commit 52cd8f7
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
24 changes: 24 additions & 0 deletions functions/__antidote_bundle_compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/zsh

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

local -a bundles
if [[ -z "$1" ]]; then
bundles=($(antidote-list --dirs))
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
# }
13 changes: 12 additions & 1 deletion functions/antidote-update
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@

if (( $#o_bundles )) || ! (( $#o_self )); then
print "Updating bundles..."
local bundledir url
local bundledir url repo
for bundledir in $(antidote-list --dirs); do
url=$(git -C "$bundledir" config remote.origin.url)
repo="${url:h:t}/${${url:t}%.git}"
print "antidote: checking for updates: $url"
() {
local oldsha=$(git -C "$1" rev-parse --short HEAD)
Expand All @@ -33,13 +34,23 @@
if [[ $oldsha != $newsha ]]; then
print "antidote: updated: $2 $oldsha -> $newsha"
fi
if zstyle -t ":antidote:bundle:$repo" compile; then
__antidote_bundle_compile $bundledir
fi
} "$bundledir" "$url" &
done
print "Waiting for bundle updates to complete..."
wait
print "Bundle updates complete."
fi

if zstyle -t ':antidote:bundle:' compile; then
builtin autoload -Uz zrecompile
zrecompile -pq "$staticfile"
elif [[ -r "${staticfile}.zwc" ]]; then
command rm -f -- "${staticfile}.zwc"
fi

# update antidote
if (( $#o_self )) || ! (( $#o_bundles )); then
print "Updating antidote..."
Expand Down
25 changes: 25 additions & 0 deletions tests/test_real.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
%
```

### Config

```zsh
% zstyle ':antidote:bundle:*' compile 'yes'
%
```

### Bundle

Clone and generate bundle script
Expand All @@ -29,6 +36,24 @@ Check to see that everything cloned
%
```

Test that everything compiled

```zsh
% # zwcfiles=($(ls $(antidote home)/**/*.zwc(N) | wc -l))
% # test $zwcfiles -gt 100 #=> --exit 0
%
```

Test that everything updated

```zsh
% rm -rf -- $(antidote home)/**/*.zwc(N)
% antidote update >/dev/null
% zwcfiles=($(ls $(antidote home)/**/*.zwc(N) | wc -l))
% # test $zwcfiles -gt 100 #=> --exit 0
%
```

Check to see that branch:br annotations properly changed the cloned branch

```zsh
Expand Down

0 comments on commit 52cd8f7

Please sign in to comment.