mirror of
https://github.com/jorgebucaran/fisher
synced 2024-11-09 07:10:27 +00:00
39 lines
1.2 KiB
Fish
39 lines
1.2 KiB
Fish
function __fisher_plugin_validate -a plugin
|
|
switch "$plugin"
|
|
case . /\* ./\* ../\*
|
|
if test ! -e $plugin
|
|
return 1
|
|
end
|
|
|
|
switch "$plugin"
|
|
case /\*
|
|
printf "%s\n" $plugin
|
|
|
|
case \*
|
|
|
|
printf "$PWD/%s/%s" (dirname $plugin) (basename $plugin)
|
|
|
|
end | sed -E 's|[./]*$||; s|/([\./])/+|/|g'
|
|
|
|
case \*
|
|
set -l id "[A-Za-z0-9._-]"
|
|
|
|
if not printf "%s\n" $plugin | grep -qE "^(($id+)[:/]*)*\$"
|
|
printf "%s\n" $plugin
|
|
return 1
|
|
end
|
|
|
|
printf "%s\n" $plugin \
|
|
| sed -E "
|
|
s|^gh[:/]+|https://github.com/|
|
|
s|^gl[:/]+|https://gitlab.com/|
|
|
s|^bb[:/]+|https://bitbucket.org/|
|
|
s|^omf[:/]+|https://github.com/oh-my-fish/|
|
|
s|^($id+)/($id+)\$|https://github.com/\1/\2|
|
|
s|^http(s?)[:/]*|http\1://|
|
|
s|https://github((.com)?/)?|https://github.com/|
|
|
s|/*(\.git/*)*\$||g" \
|
|
| tr "[A-Z]" "[a-z]"
|
|
end
|
|
end
|