From 0c2d939e02779a80561d2e77aad3a4056bb230b8 Mon Sep 17 00:00:00 2001 From: Niraj Thapaliya Date: Thu, 14 Dec 2017 22:13:09 -0600 Subject: [PATCH] `yarn run` tab completion completes #4597 --- share/completions/yarn.fish | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/share/completions/yarn.fish b/share/completions/yarn.fish index 86d63b165..4266e9909 100644 --- a/share/completions/yarn.fish +++ b/share/completions/yarn.fish @@ -64,6 +64,16 @@ complete -f -c yarn -n '__fish_seen_subcommand_from publish' -l tag complete -f -c yarn -n '__fish_use_subcommand' -a remove complete -f -c yarn -n '__fish_use_subcommand' -a run +function __fish_yarn_run + if test -e package.json; and type -q jq + jq -r '.scripts | to_entries | map("\(.key)\t\(.value | tostring | .[0:20])") | .[]' package.json + else if type -q jq + command yarn run --json 2> /dev/null | jq -r '.data.hints? | to_entries | map("\(.key)\t\(.value | tostring |.[0:20])") | .[]' + end +end + +complete -f -c yarn -n '__fish_seen_subcommand_from run' -a "(__fish_yarn_run)" + complete -f -c yarn -n '__fish_use_subcommand' -a tag complete -f -c yarn -n '__fish_seen_subcommand_from tag' -a 'add rm ls'