mirror of https://github.com/jorgebucaran/fisher
Ahoy! Fisherman 1.4.0 has shipped.
Notable changes: + Now fisher list does not show plugins that are disabled, but available in the cache. To preview these items use fisher list --disabled. + Welcome aboard @orangecms and @xrain0610. + Fisherman is now available in AUR, thanks @orangecms. + Fix load order during installation. Now snippets can safely invoke functions defined in the plugin function directory. Thanks @orangecms. #170. + Fisherman **installs and updates plugins ⌁concurrently**. Performance may vary, but if you can see 5 to 10 times faster network times, it's working well.pull/445/head
parent
fca41816e1
commit
6c5cac3a18
@ -1,3 +1,3 @@
|
||||
function __fisher_cache_list
|
||||
find -L $fisher_cache/* -maxdepth 0 -type d ^ /dev/null | sed 's|.*/||'
|
||||
command find -L $fisher_cache/* -maxdepth 0 -type d ^ /dev/null | sed 's|.*/||'
|
||||
end
|
||||
|
@ -1,7 +0,0 @@
|
||||
function __fisher_deps_install -a path
|
||||
for file in $path/{fishfile,bundle}
|
||||
if test -s $file
|
||||
fisher_install < $file | sed -En 's|^([0-9]+) plugin/s installed.*|\1|p'
|
||||
end
|
||||
end | awk '{ n = n + $0 } END { print n ? n : 0 }'
|
||||
end
|
@ -1,12 +0,0 @@
|
||||
function __fisher_function_to_plugin -a name
|
||||
if test -d "$name"
|
||||
return 1
|
||||
end
|
||||
|
||||
set -l path (pwd)/$name
|
||||
mkdir -p "$path"
|
||||
|
||||
functions -- $name | fish_indent > "$path/$name.fish"
|
||||
|
||||
printf "%s\n" "$path"
|
||||
end
|
@ -0,0 +1,127 @@
|
||||
function -S __fisher_plugin_fetch
|
||||
set -l plugins
|
||||
set -l fetched
|
||||
|
||||
for item in $argv
|
||||
if not set item (__fisher_plugin_validate "$item")
|
||||
printf "fisher: '%s' is not a valid plugin\n" "$item" > $stderr
|
||||
debug "validate fail %s" "$item"
|
||||
continue
|
||||
end
|
||||
|
||||
debug "validate ok %s" "$item"
|
||||
|
||||
if contains -- "$item" $enabled
|
||||
if test -z "$option"
|
||||
set skipped $skipped "$item"
|
||||
debug "skip %s" "$item"
|
||||
continue
|
||||
end
|
||||
end
|
||||
|
||||
switch "$item"
|
||||
case \*/\*
|
||||
set plugins $plugins "$item"
|
||||
debug "url or path %s" $item
|
||||
|
||||
case \*
|
||||
if test -d "$fisher_cache/$item"
|
||||
set -l url (__fisher_url_from_path "$fisher_cache/$item")
|
||||
|
||||
if test ! -z "$url"
|
||||
set plugins $plugins "$url"
|
||||
end
|
||||
|
||||
debug "cache %s" "$item"
|
||||
|
||||
else
|
||||
if test ! -s $fisher_cache/.index
|
||||
if spin "__fisher_index_update" --error=/dev/null > /dev/null
|
||||
debug "update index ok"
|
||||
else
|
||||
debug "update index fail"
|
||||
end
|
||||
end
|
||||
|
||||
if set -l url (fisher_search --url --name="$item" --index=$fisher_cache/.index)
|
||||
set plugins $plugins "$url"
|
||||
debug "name %s" $item
|
||||
|
||||
else
|
||||
printf "fisher: I couldn't find '%s' in the index\n" $item > $stderr
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for plugin in $plugins
|
||||
set -l name (echo $plugin | __fisher_name)
|
||||
set -l path $fisher_cache/$name
|
||||
|
||||
switch "$plugin"
|
||||
case {https://,}gist.github.com\*
|
||||
debug "gist %s" $item
|
||||
|
||||
if not set name (__fisher_gist_to_name $plugin)
|
||||
printf "fisher: I could not find your gist\n" > $stderr
|
||||
continue
|
||||
end
|
||||
end
|
||||
|
||||
printf "%s\n" "$name"
|
||||
debug "plugin %s" "$name"
|
||||
|
||||
if test ! -e $path
|
||||
if not set -q __fisher_fetch_status
|
||||
set -g __fisher_fetch_status
|
||||
printf "Installing plugin/s\n" > $stderr
|
||||
|
||||
else if test "$__fisher_fetch_status" = "deep"
|
||||
printf "Installing dependencies\n" > $stderr
|
||||
set -g __fisher_fetch_status done
|
||||
end
|
||||
|
||||
set fetched $fetched "$path"
|
||||
|
||||
if test -d "$plugin"
|
||||
debug "link %s" "$plugin"
|
||||
command ln -sfF $plugin $path
|
||||
|
||||
else
|
||||
debug "clone %s" "$plugin"
|
||||
fish -ic "
|
||||
spin '
|
||||
if __fisher_url_clone $plugin $path
|
||||
printf \" %-20s\n\" \"$name\"
|
||||
end
|
||||
' > $stderr
|
||||
" &
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if test ! -z "$plugins"
|
||||
while true
|
||||
set -l has_jobs (jobs)
|
||||
if test -z "$has_jobs"
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
switch "$__fisher_fetch_status"
|
||||
case done deep
|
||||
case \*
|
||||
set __fisher_fetch_status deep
|
||||
end
|
||||
|
||||
for path in $fetched
|
||||
for file in $path/{fishfile,bundle}
|
||||
if test -s $file
|
||||
__fisher_plugin_fetch (__fisher_file < $file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set -e __fisher_fetch_status
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
function __fisher_plugin_link -a options source target
|
||||
debug "Link %s" $target
|
||||
debug "link %s" $target
|
||||
command ln $options $source $target
|
||||
end
|
||||
|
@ -1,9 +1,9 @@
|
||||
function __fisher_plugin_unlink -a file name
|
||||
debug "Unlink %s" $file
|
||||
debug "unlink %s" $file
|
||||
command rm -f $file
|
||||
|
||||
if test ! -z "$name"
|
||||
debug "Erase %s" $name
|
||||
debug "erase %s" $name
|
||||
functions -e $name
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
function __fisher_url_clone -a url path
|
||||
set -lx GIT_ASKPASS /bin/echo
|
||||
set -lx GIT_ASKPASS /bin/echo
|
||||
git clone -q --depth 1 $url $path
|
||||
end
|
||||
|
@ -1,31 +0,0 @@
|
||||
set -l path $DIRNAME/.t-$TESTNAME-(random)
|
||||
|
||||
function -S setup
|
||||
mkdir -p $path $path/void
|
||||
|
||||
printf "%s\n" foo bar > $path/bundle
|
||||
printf "%s\n" baz norf > $path/fishfile
|
||||
|
||||
function fisher_install
|
||||
set -l count 0
|
||||
|
||||
while read -l plugin
|
||||
set count (math $count + 1)
|
||||
end
|
||||
|
||||
echo "$count plugin/s installed."
|
||||
end
|
||||
end
|
||||
|
||||
function -S teardown
|
||||
rm -rf $path
|
||||
functions -e fisher_install
|
||||
end
|
||||
|
||||
test "$TESTNAME - Install dependencies from one or more bundle/fishfile files"
|
||||
(__fisher_deps_install $path ^ /dev/null) = 4
|
||||
end
|
||||
|
||||
test "$TESTNAME - Print 0 to indicate no dependencies were installed"
|
||||
(__fisher_deps_install $path/void) = 0
|
||||
end
|
@ -1,31 +0,0 @@
|
||||
set -l path $DIRNAME/.t-$TESTNAME-(random)
|
||||
|
||||
function -S setup
|
||||
mkdir -p $path
|
||||
|
||||
function foobar
|
||||
echo foobar
|
||||
end
|
||||
end
|
||||
|
||||
function -S teardown
|
||||
rm -rf $path
|
||||
functions -e foobar
|
||||
end
|
||||
|
||||
test "$TESTNAME - Return the path where the plugin was created"
|
||||
$path/foobar = (
|
||||
pushd $path
|
||||
__fisher_function_to_plugin foobar
|
||||
popd
|
||||
)
|
||||
end
|
||||
|
||||
test "$TESTNAME - Create a file with the contents of the given function"
|
||||
(functions foobar | xargs) = (
|
||||
pushd $path
|
||||
set -l plugin_path (__fisher_function_to_plugin foobar)
|
||||
cat $plugin_path/foobar.fish | xargs
|
||||
popd
|
||||
)
|
||||
end
|
Loading…
Reference in New Issue