mirror of
https://github.com/zdharma-continuum/zinit-annex-bin-gem-node.git
synced 2026-09-10 07:26:18 -04:00
feat: zsh-sweep linter fixes (#23)
* Make any binary name given to sbin'' ice be searched via preceding **/…
This allows to simply leave the ice empty, to find **/$id_as or **/$plugin,
or specify a binary name without need to give it a **/… glob, because
it is boring to do, as someone once noted (didn't find the post).
Second change is a new "1:…" option to limit the number of shims created
to only 1. So, e.g.: `sbin'1:exa*'` to have only first, shortest path
exa found be given a shim.
* maint: Switch from `print -P %F{col-nr}` to `m {col-name}`.
The `m` function is automatically provided for the moment of loading/installing
a plugin and it's the same as `+zinit-message`.
* maint: fix reports from zsh-sweep linter
This commit is contained in:
parent
10a706e8ce
commit
0fe8fec773
|
|
@ -4,7 +4,9 @@
|
|||
za-bgn-atclone-handler() {
|
||||
|
||||
emulate -RL zsh
|
||||
setopt extendedglob warncreateglobal typesetsilent noshortloops
|
||||
setopt extendedglob warncreateglobal typesetsilent noshortloops nopromptsubst
|
||||
|
||||
0=${${(M)${0::=${(%):-%x}}:#/*}:-$PWD/$0}
|
||||
|
||||
if [[ "$1" = plugin ]] {
|
||||
local type="$1" user="$2" plugin="$3" id_as="$4" dir="${5#%}" hook="$6"
|
||||
|
|
@ -42,7 +44,7 @@ if [[ -n "${ICE[gem]}" ]] {
|
|||
command gem install -q --no-user-install -i "$dir" "${gems[@]}"
|
||||
elif [[ $hook = *atpull-<-> ]]; then
|
||||
if (( !OPTS[opt_-q,--quiet] )) {
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{154}Updating the gems...%f"
|
||||
m {pre}bin-gem-node annex: {msg2}Updating the gems...
|
||||
command gem update -q --no-user-install -i "$dir" "${gems[@]}"
|
||||
} else {
|
||||
command gem update -q --no-user-install -i "$dir" "${gems[@]}" &> /dev/null
|
||||
|
|
@ -86,9 +88,10 @@ if [[ -n "${ICE[pip]}" ]] {
|
|||
|
||||
(( perform_update )) && (( ${#umods} )) && \
|
||||
(
|
||||
local -x VIRTUALENV
|
||||
builtin cd -q "$dir" && {
|
||||
if (( !OPTS[opt_-q,--quiet] )) {
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{154}Updating the pip packages...%f"
|
||||
m {pre}bin-gem-node annex: {msg2}Updating the pip packages...
|
||||
VIRTUALENV=venv(:A) command venv/bin/pip install --upgrade "${umods[@]}"
|
||||
} else {
|
||||
VIRTUALENV=venv(:A) command venv/bin/pip install -q --upgrade "${umods[@]}"
|
||||
|
|
@ -133,7 +136,7 @@ if [[ -n "${ICE[node]}" ]] {
|
|||
(
|
||||
builtin cd -q "$dir" && {
|
||||
if (( !OPTS[opt_-q,--quiet] )) {
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{154}Updating the node modules...%f"
|
||||
m {pre}bin-gem-node annex: {msg2}Updating the node modules...
|
||||
command npm --silent update
|
||||
} else {
|
||||
command npm --silent update &> /dev/null
|
||||
|
|
@ -178,13 +181,12 @@ if (( ${+ICE[sbin]} )) {
|
|||
if (( ${#files} )); then
|
||||
sbin="${files[1]}"
|
||||
else
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{160}The automatic-empty sbin ice didn't find any executable files%f"
|
||||
m {pre}bin-gem-node annex: {error}The automatic-empty sbin ice didn\'t find any executable files
|
||||
break
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Allow multiple separators, =>,->,→
|
||||
srcdst=( ${(@s.=>.)${(@s.→.)${(@s.->.)sbin}}} )
|
||||
srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
|
||||
[[ ${srcdst[1]} = [1gnpcNEO]#g[1gnpcNEO]#:* ]] && set_gem_home=1
|
||||
|
|
@ -209,7 +211,8 @@ if (( ${+ICE[sbin]} )) {
|
|||
eval "fnames=( ${srcdst[1]}(Nnon-.) )"
|
||||
fi
|
||||
if (( !${#fnames} )) {
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{160}Warning: %F{154}The sbin'' ice (\`%F{219}$sbin%F{154}') didn't match any files%f"
|
||||
m {pre}bin-gem-node annex: {error}Warning: {msg2}The sbin\'\' \
|
||||
ice \(\`{ice}$sbin{msg2}'\) didn\'t match any files
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +234,7 @@ if (( ${+ICE[sbin]} )) {
|
|||
command chmod +x "$file.cmd"
|
||||
continue
|
||||
fi
|
||||
|
||||
|
||||
.za-bgn-bin-or-src-function-body 0 \
|
||||
"$fnam" \
|
||||
"$target_binary" "$dir" "$set_gem_home" \
|
||||
|
|
@ -246,13 +249,13 @@ if (( ${+ICE[sbin]} )) {
|
|||
(( !OPTS[opt_-q,--quiet] )) && \
|
||||
if [[ -x $target_binary ]]; then
|
||||
if [[ $hook == atclone-<-> || $ZINIT[annex-multi-flag:pull-active] -ge 2 ]] {
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{154}${${${hook:#*atclone-<->}:+Re-c}:-C}reated the %F{219}$fnam%F{154} shim and set +x on the %F{219}${target_binary:t}%F{154} binary%f"
|
||||
m {pre}bin-gem-node annex: {msg2}${${${hook:#*atclone-<->}:+Re-c}:-C}reated the {cmd}$fnam{msg2} shim and set +x on the {cmd}${target_binary:t}{msg2} binary
|
||||
}
|
||||
else
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{154}${${${hook:#*atclone-<->}:+Re-c}:-C}reated the %F{219}$fnam%F{154} shim %F{160}however the %F{219}${target_binary:t}%F{160} binary does not exist or failed to set +x on it%f"
|
||||
m {pre}bin-gem-node annex: {msg2}${${${hook:#*atclone-<->}:+Re-c}:-C}reated the {cmd}$fnam{msg2} shim {error}however the {cmd}${target_binary:t}{error} binary does not exist or failed to set +x on it
|
||||
fi
|
||||
else
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{160}Something went wrong creating the %F{219}$fnam%F{160} shim%f"
|
||||
m {pre}bin-gem-node annex: {error}Something went wrong creating the {cmd}$fnam{error} shim
|
||||
fi
|
||||
if ((use_1)); then
|
||||
(($#fnames-1)) && \
|
||||
|
|
@ -287,9 +290,9 @@ if [[ -n "${ICE[fbin]}" ]] {
|
|||
|
||||
if [[ -x $target_binary ]]; then
|
||||
(( !OPTS[opt_-q,--quiet] )) && \
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{154}Set +x on the %F{219}${target_binary:t}%F{154} binary%f"
|
||||
m {pre}bin-gem-node annex: {msg2}Set +x on the {cmd}${target_binary:t}{msg2} binary
|
||||
else
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{160}Something went wrong setting +x on the %F{219}${target_binary:t}%F{160} binary%f"
|
||||
m {pre}bin-gem-node annex: {error}Something went wrong setting +x on the {cmd}${target_binary:t}{error} binary
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
# Copyright (c) 2019-2020 Sebastian Gniazdowski
|
||||
# License MIT
|
||||
|
||||
za-bgn-atdelete-handler() {
|
||||
|
||||
emulate -RL zsh
|
||||
setopt extendedglob warncreateglobal typesetsilent noshortloops
|
||||
setopt extendedglob warncreateglobal typesetsilent noshortloops nopromptsubst
|
||||
|
||||
0=${${(M)${0::=${(%):-%x}}:#/*}:-$PWD/$0}
|
||||
|
||||
[[ "$1" = plugin ]] && \
|
||||
local type="$1" user="$2" plugin="$3" id_as="$4" dir="$5" hook="$6" || \
|
||||
|
|
@ -37,7 +41,7 @@ if (( ${+ICE[sbin]} )) {
|
|||
if (( ${#files} )); then
|
||||
sbin="${files[1]}"
|
||||
else
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{160}The automatic-empty sbin ice didn't find any executable files%f"
|
||||
m {pre}bin-gem-node annex: {error}The automatic-empty sbin ice didn\'t find any executable files
|
||||
break
|
||||
fi
|
||||
fi
|
||||
|
|
@ -67,16 +71,17 @@ if (( ${+ICE[sbin]} )) {
|
|||
if [[ -f $file ]]; then
|
||||
command rm -f "$file"
|
||||
if [[ -f $file ]]; then
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{160}Couldn't remove the %F{220}$fnam%F{160} shim from \$ZPFX/bin (no write access to \$ZPFX/bin?)%f"
|
||||
m {pre}bin-gem-node annex: {error}Couldn\'t remove the {cmd}$fnam{error} shim from {dir}\$ZPFX/bin{error} \(no write access to {dir}\$ZPFX/bin{error}?\)
|
||||
else
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{154}Correctly removed the %F{220}$fnam%F{154} shim from \$ZPFX/bin%f" || \
|
||||
m {pre}bin-gem-node annex: {msg2}Correctly removed the {cmd}$fnam{msg2} shim from {dir}\$ZPFX/bin
|
||||
fi
|
||||
else
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{160}The %F{220}$fnam%F{160} shim didn't exist in \$ZPFX/bin (or isn't a regular file)%f"
|
||||
m {pre}bin-gem-node annex: {error}The {cmd}$fnam{error} shim didn\'t exist in {dir}\$ZPFX/bin{error} (or isn\'t a regular file)
|
||||
fi
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
# vim:ft=zsh:sw=4:sts=4:et
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@
|
|||
za-bgn-atload-handler() {
|
||||
|
||||
emulate -RL zsh
|
||||
setopt extendedglob warncreateglobal typesetsilent noshortloops
|
||||
setopt extendedglob warncreateglobal typesetsilent noshortloops nopromptsubst
|
||||
|
||||
0=${${(M)${0::=${(%):-%x}}:#/*}:-$PWD/$0}
|
||||
|
||||
if [[ "$1" = plugin ]] {
|
||||
local type="$1" user="$2" plugin="$3" id_as="$4" dir="${5#%}" hook="$6"
|
||||
|
|
@ -150,7 +152,9 @@ if (( ${+ICE[fbin]}${+ICE[fsrc]}${+ICE[ferc]} > 0 )) {
|
|||
if (( ${#files} )); then
|
||||
fbin="${files[1]}"
|
||||
else
|
||||
print -P -- "%F{38}bin-gem-node annex: %F{160}The automatic-empty fbin ice didn't find any executable files for %F{219}$id_as%f"
|
||||
m {pre}bin-gem-node annex: {error}The automatic-empty \
|
||||
{ice}fbin{error} ice didn\'t find any executable \
|
||||
files for {id-as}$id_as
|
||||
break
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -11,10 +11,12 @@
|
|||
za-bgn-shim-list() {
|
||||
|
||||
emulate -LR zsh
|
||||
setopt extended_glob warn_create_global typeset_silent \
|
||||
no_short_loops rc_quotes
|
||||
setopt extendedglob warncreateglobal typesetsilent \
|
||||
noshortloops rcquotes nopromptsubst
|
||||
|
||||
autoload is-at-least
|
||||
0=${${(M)${0::=${(%):-%x}}:#/*}:-$PWD/$0}
|
||||
|
||||
autoload -Uz is-at-least
|
||||
local is_58
|
||||
is-at-least 5.8 && is_58=1
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue