Skip to content

Commit

Permalink
Initial binary support (zsh-users#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
desyncr committed Mar 12, 2017
1 parent 4908b97 commit 7dc408a
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 50 deletions.
58 changes: 33 additions & 25 deletions bin/antigen.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,17 @@ fi
return
fi

# If there is no `*.plugin.zsh` file, source *all* the `*.zsh` files.
local bundle_files
bundle_files=($location/*.zsh(N) $location/*.sh(N))
if [[ $#bundle_files -gt 0 ]]; then
echo "${(j:\n:)bundle_files}"
# If there is no `*.plugin.zsh` file, source *all* the `*.zsh` files.
local bundle_files
bundle_files=($location/*.zsh(N) $location/*.sh(N))
if [[ $#bundle_files -gt 0 ]]; then
echo "${(j:\n:)bundle_files}"
return
fi

# Add to PATH (binary bundle)
echo "$location"
return
fi
}

# Parses a bundle url in bundle-metadata format: url[|branch]
Expand Down Expand Up @@ -563,11 +567,14 @@ fi
local make_local_clone="$3"
local btype="$4"
local src

for src in $(-antigen-load-list "$url" "$loc" "$make_local_clone" "$btype"); do
# TODO Refactor this out
if [[ -d "$src" ]]; then
if (( ! ${fpath[(I)$location]} )); then
fpath=($location $fpath)
fi
if (( ! ${fpath[(I)$src]} )); then
fpath=($src $fpath)
fi
PATH="$PATH:$src"
else
# Hack away local variables. See https://github.com/zsh-users/antigen/issues/122
# This is needed to seek-and-destroy local variable definitions *outside*
Expand Down Expand Up @@ -1350,22 +1357,23 @@ _antigen () {
# Returns
# Nothing. Generates _ZCACHE_META_PATH and _ZCACHE_PAYLOAD_PATH
-zcache-generate-cache () {
local -aU _extensions_paths
local -a _bundles_meta
local _payload=''
local location
_payload+="#-- START ZCACHE GENERATED FILE\NL"
_payload+="#-- GENERATED: $(date)\NL"
_payload+='#-- ANTIGEN v1.4.1\NL'
for bundle in $_ZCACHE_BUNDLES; do
# -antigen-load-list "$url" "$loc" "$make_local_clone"
eval "$(-antigen-parse-bundle ${=bundle})"
_bundles_meta+=("$url $loc $btype $make_local_clone $branch")
if $make_local_clone; then
-antigen-ensure-repo "$url"
fi
local -aU _extensions_paths
local -aU _binary_paths
local -a _bundles_meta
local _payload=''
local location
_payload+="#-- START ZCACHE GENERATED FILE\NL"
_payload+="#-- GENERATED: $(date)\NL"
_payload+='#-- ANTIGEN v1.4.1\NL'
for bundle in $_ZCACHE_BUNDLES; do
# -antigen-load-list "$url" "$loc" "$make_local_clone"
eval "$(-antigen-parse-bundle ${=bundle})"
_bundles_meta+=("$url $loc $btype $make_local_clone $branch")
if $make_local_clone; then
-antigen-ensure-repo "$url"
fi
-antigen-load-list "$url" "$loc" "$make_local_clone" | while read line; do
if [[ -f "$line" ]]; then
Expand Down
33 changes: 17 additions & 16 deletions src/ext/zcache/functions.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,23 @@
# Returns
# Nothing. Generates _ZCACHE_META_PATH and _ZCACHE_PAYLOAD_PATH
-zcache-generate-cache () {
local -aU _extensions_paths
local -a _bundles_meta
local _payload=''
local location

_payload+="#-- START ZCACHE GENERATED FILE\NL"
_payload+="#-- GENERATED: $(date)\NL"
_payload+='#-- ANTIGEN {{ANTIGEN_VERSION}}\NL'
for bundle in $_ZCACHE_BUNDLES; do
# -antigen-load-list "$url" "$loc" "$make_local_clone"
eval "$(-antigen-parse-bundle ${=bundle})"
_bundles_meta+=("$url $loc $btype $make_local_clone $branch")

if $make_local_clone; then
-antigen-ensure-repo "$url"
fi
local -aU _extensions_paths
local -aU _binary_paths
local -a _bundles_meta
local _payload=''
local location

_payload+="#-- START ZCACHE GENERATED FILE\NL"
_payload+="#-- GENERATED: $(date)\NL"
_payload+='#-- ANTIGEN {{ANTIGEN_VERSION}}\NL'
for bundle in $_ZCACHE_BUNDLES; do
# -antigen-load-list "$url" "$loc" "$make_local_clone"
eval "$(-antigen-parse-bundle ${=bundle})"
_bundles_meta+=("$url $loc $btype $make_local_clone $branch")

if $make_local_clone; then
-antigen-ensure-repo "$url"
fi

-antigen-load-list "$url" "$loc" "$make_local_clone" | while read line; do
if [[ -f "$line" ]]; then
Expand Down
16 changes: 10 additions & 6 deletions src/helpers/load-list.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@
return
fi

# If there is no `*.plugin.zsh` file, source *all* the `*.zsh` files.
local bundle_files
bundle_files=($location/*.zsh(N) $location/*.sh(N))
if [[ $#bundle_files -gt 0 ]]; then
echo "${(j:\n:)bundle_files}"
# If there is no `*.plugin.zsh` file, source *all* the `*.zsh` files.
local bundle_files
bundle_files=($location/*.zsh(N) $location/*.sh(N))
if [[ $#bundle_files -gt 0 ]]; then
echo "${(j:\n:)bundle_files}"
return
fi

# Add to PATH (binary bundle)
echo "$location"
return
fi
}

9 changes: 6 additions & 3 deletions src/lib/load.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
local make_local_clone="$3"
local btype="$4"
local src

for src in $(-antigen-load-list "$url" "$loc" "$make_local_clone" "$btype"); do
# TODO Refactor this out
if [[ -d "$src" ]]; then
if (( ! ${fpath[(I)$location]} )); then
fpath=($location $fpath)
fi
if (( ! ${fpath[(I)$src]} )); then
fpath=($src $fpath)
fi
PATH="$PATH:$src"
else
# Hack away local variables. See https://github.com/zsh-users/antigen/issues/122
# This is needed to seek-and-destroy local variable definitions *outside*
Expand Down
18 changes: 18 additions & 0 deletions tests/.zshenv
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ echo 'alias unsourced-alias="echo unsourced-alias"' > "$PLUGIN_DIR2"/aliases.zsh
pg2 commit -m 'Initial commit'
} > /dev/null

# Another test plugin.

export PLUGIN_DIR3="$PWD/test-plugin3"
mkdir "$PLUGIN_DIR3"

# A wrapper function over `git` to work with the test plugin repo.
alias pg3='git --git-dir "$PLUGIN_DIR3/.git" --work-tree "$PLUGIN_DIR3"'

echo "echo '######'" > "$PLUGIN_DIR3"/hr
chmod u+x "$PLUGIN_DIR3"/hr

{
pg3 init
pg3 add .
pg3 commit -m 'Initial commit'
} > /dev/null

# Wrapper around \wc command to handle wc format differences between GNU and BSD
# GNU:
# echo 1 | wc -l
Expand All @@ -76,3 +93,4 @@ echo 'alias unsourced-alias="echo unsourced-alias"' > "$PLUGIN_DIR2"/aliases.zsh
function wc () {
command wc "$@" | xargs
}

10 changes: 10 additions & 0 deletions tests/bundle.t
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,13 @@ Handle local bundles (--no-local-clone).

$ -antigen-bundle-short-name "/home/user/local-bundle"
user/local-bundle

Load a binary bundle.

$ antigen-bundle $PLUGIN_DIR3 &> /dev/null
$ hr
######

$ echo $PATH | grep test-plugin3
*plugin3* (glob)

0 comments on commit 7dc408a

Please sign in to comment.