mirror of
https://github.com/zdharma-continuum/zinit-annex-bin-gem-node.git
synced 2026-09-10 07:26:18 -04:00
plugin.zsh,*mod*body,*atload-handler: Make *-mod-function-body autoload
This commit is contained in:
parent
0ef896d158
commit
061d8073dc
23
.za-bgn-mod-function-body
Normal file
23
.za-bgn-mod-function-body
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Copyright (c) 2019 Sebastian Gniazdowski
|
||||
# License MIT
|
||||
#
|
||||
# Returns the body of the function wrapping a function
|
||||
|
||||
local name="$1" target_func="$2" dir="$3"
|
||||
integer set_gem_home="$4" set_node_path="$5" set_cwd="$6"
|
||||
|
||||
if [[ "$name" = "$target_func" ]]; then
|
||||
target_func="${target_func}--za-bgn-orig"
|
||||
functions[$target_func]="${functions[$name]}"
|
||||
fi
|
||||
|
||||
REPLY="function $name {
|
||||
${${(M)set_gem_home:#1}:+local -x GEM_HOME=${(qqq)dir}}
|
||||
${${(M)set_node_path:#1}:+local -x NODE_PATH=${(qqq)dir}/node_modules}
|
||||
${${(M)set_cwd:#1}:+"local oldpwd=${(qqq)PWD}
|
||||
() { setopt localoptions noautopushd; builtin cd -q ${(qqq)dir}; }"}
|
||||
${(qqq)target_func} \"\$@\"
|
||||
${${(M)set_cwd:#1}:+"() { setopt localoptions noautopushd; builtin cd -q \"\$oldpwd\"; }"}
|
||||
}"
|
||||
|
||||
# vim:ft=zsh:sw=4:sts=4:et
|
||||
|
|
@ -48,28 +48,6 @@ local nl=$'\n'
|
|||
return 0
|
||||
} # }}}
|
||||
|
||||
# FUNCTION: .za-bgn-mod-function-body {{{
|
||||
# Returns the body of the function wrapping a function
|
||||
.za-bgn-mod-function-body() {
|
||||
local name="$1" target_func="$2" dir="$3"
|
||||
integer set_gem_home="$4" set_node_path="$5" set_cwd="$6"
|
||||
|
||||
if [[ "$name" = "$target_func" ]]; then
|
||||
target_func="${target_func}--za-bgn-orig"
|
||||
functions[$target_func]="${functions[$name]}"
|
||||
fi
|
||||
|
||||
REPLY="function $name {
|
||||
${${(M)set_gem_home:#1}:+local -x GEM_HOME=${(qqq)dir}}
|
||||
${${(M)set_node_path:#1}:+local -x NODE_PATH=${(qqq)dir}/node_modules}
|
||||
${${(M)set_cwd:#1}:+"local oldpwd=${(qqq)PWD}
|
||||
() { setopt localoptions noautopushd; builtin cd -q ${(qqq)dir}; }"}
|
||||
${(qqq)target_func} \"\$@\"
|
||||
${${(M)set_cwd:#1}:+"() { setopt localoptions noautopushd; builtin cd -q \"\$oldpwd\"; }"}
|
||||
}"
|
||||
}
|
||||
# }}}
|
||||
|
||||
#
|
||||
# gem'' ice
|
||||
#
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
|
||||
autoload .za-bgn-bin-or-src-function-body \
|
||||
.za-bgn-mod-function-body \
|
||||
:za-bgn-atload-handler :za-bgn-atclone-handler \
|
||||
:za-bgn-atpull-handler :za-bgn-help-handler \
|
||||
:za-bgn-atdelete-handler
|
||||
|
|
|
|||
Loading…
Reference in a new issue