mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 05:53:59 +00:00
Fix npm run completion executing only on completions load, also:
* Better handling of `npm run` output
This commit is contained in:
parent
cba3db6205
commit
527c932e93
1 changed files with 15 additions and 8 deletions
|
@ -58,6 +58,21 @@ end
|
||||||
# and: https://github.com/fish-shell/fish-shell/pull/2366
|
# and: https://github.com/fish-shell/fish-shell/pull/2366
|
||||||
complete -f -c npm -n 'not __fish_npm_needs_option' -a "(__fish_complete_npm)"
|
complete -f -c npm -n 'not __fish_npm_needs_option' -a "(__fish_complete_npm)"
|
||||||
|
|
||||||
|
# list available npm scripts and their parial content
|
||||||
|
function __fish_npm_run
|
||||||
|
command npm run | command grep -v '^[^ ]' | command grep -v '^$' | command sed "s/^ *//" | while read -l name
|
||||||
|
set -l trim 20
|
||||||
|
read -l value
|
||||||
|
echo "$value" | cut -c1-$trim | read -l value
|
||||||
|
printf "%s\t%s\n" $name $value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# run
|
||||||
|
for c in run run-script
|
||||||
|
complete -f -c npm -n "__fish_npm_using_command $c" -a "(__fish_npm_run)"
|
||||||
|
end
|
||||||
|
|
||||||
# cache
|
# cache
|
||||||
complete -f -c npm -n '__fish_npm_needs_command' -a 'cache' -d "Manipulates package's cache"
|
complete -f -c npm -n '__fish_npm_needs_command' -a 'cache' -d "Manipulates package's cache"
|
||||||
complete -f -c npm -n '__fish_npm_using_command cache' -a 'add' -d 'Add the specified package to the local cache'
|
complete -f -c npm -n '__fish_npm_using_command cache' -a 'add' -d 'Add the specified package to the local cache'
|
||||||
|
@ -123,14 +138,6 @@ for c in 'up' 'update'
|
||||||
complete -f -c npm -n "__fish_npm_using_command $c" -s g -l global -d 'Update global package(s)'
|
complete -f -c npm -n "__fish_npm_using_command $c" -s g -l global -d 'Update global package(s)'
|
||||||
end
|
end
|
||||||
|
|
||||||
# run
|
|
||||||
command npm run | command tail -n +2 | command sed "s/^ *//" | while read -l name
|
|
||||||
set -l trim 20
|
|
||||||
read -l value
|
|
||||||
complete -f -c npm -n "__fish_npm_using_command run" -a (printf "%s " "$name") -d (echo "$value" | cut -c1-$trim)
|
|
||||||
complete -f -c npm -n "__fish_npm_using_command run-script" -a (printf "%s " "$name") -d (echo "$value" | cut -c1-$trim)
|
|
||||||
end
|
|
||||||
|
|
||||||
# misc shorter explanations
|
# misc shorter explanations
|
||||||
complete -f -c npm -n '__fish_npm_needs_command' -a 'adduser add-user login' -d 'Add a registry user account'
|
complete -f -c npm -n '__fish_npm_needs_command' -a 'adduser add-user login' -d 'Add a registry user account'
|
||||||
complete -f -c npm -n '__fish_npm_needs_command' -a 'bin' -d 'Display npm bin folder'
|
complete -f -c npm -n '__fish_npm_needs_command' -a 'bin' -d 'Display npm bin folder'
|
||||||
|
|
Loading…
Reference in a new issue