mirror of
https://github.com/zdharma-continuum/zinit-annex-bin-gem-node.git
synced 2025-01-30 16:58:17 +01:00
31 lines
1.1 KiB
Bash
31 lines
1.1 KiB
Bash
# 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_virtualenv="$6" set_cwd="$7" \
|
|
use_all_null="$8" use_err_null="$9" use_out_null="$10"
|
|
|
|
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_virtualenv:#1}:+local -x VIRTUALENV=${(qqq)dir}/venv}
|
|
${${(M)set_cwd:#1}:+"local oldpwd=${(qqq)PWD}
|
|
() { setopt localoptions noautopushd; builtin cd -q ${(qqq)dir}; }"}
|
|
${(qqq)target_func} \"\$@\""
|
|
|
|
(( use_all_null )) && REPLY+=" &>/dev/null"
|
|
(( use_err_null )) && REPLY+=" 2>/dev/null"
|
|
(( use_out_null )) && REPLY+=" >/dev/null"
|
|
|
|
REPLY+="$nl"
|
|
REPLY+="${${(M)set_cwd:#1}:+"() { setopt localoptions noautopushd; builtin cd -q \"\$oldpwd\"; }"}
|
|
}"
|
|
|
|
# vim:ft=zsh:sw=4:sts=4:et
|