mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-27 03:13:37 +08: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
|
@ -58,6 +58,21 @@ end
|
|||
# and: https://github.com/fish-shell/fish-shell/pull/2366
|
||||
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
|
||||
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'
|
||||
|
@ -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)'
|
||||
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
|
||||
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'
|
||||
|
|
Loading…
Reference in New Issue
Block a user