aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--share/completions/npm.fish23
1 files changed, 15 insertions, 8 deletions
diff --git a/share/completions/npm.fish b/share/completions/npm.fish
index 4120b3a9..05393b85 100644
--- a/share/completions/npm.fish
+++ b/share/completions/npm.fish
@@ -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'