aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornicoulaj <julien.nicoulaud@gmail.com>2019-10-08 18:54:55 +0200
committerGitHub <noreply@github.com>2019-10-08 18:54:55 +0200
commit87e131334fbb08e1622eff5cf27efead23875c4f (patch)
tree80f117e58de28dad05f213f72783926dfd1cb142 /src
parentMerge pull request #654 from bondz/patch-1 (diff)
parentrevert: suggest binaries on `yarn` (diff)
downloadzsh-completions-87e131334fbb08e1622eff5cf27efead23875c4f.tar
zsh-completions-87e131334fbb08e1622eff5cf27efead23875c4f.tar.gz
zsh-completions-87e131334fbb08e1622eff5cf27efead23875c4f.tar.bz2
zsh-completions-87e131334fbb08e1622eff5cf27efead23875c4f.tar.lz
zsh-completions-87e131334fbb08e1622eff5cf27efead23875c4f.tar.xz
zsh-completions-87e131334fbb08e1622eff5cf27efead23875c4f.tar.zst
zsh-completions-87e131334fbb08e1622eff5cf27efead23875c4f.zip
Merge pull request #653 from MaximDevoir/feat/improve-yarn-suggestions
YARN | Improve suggestions for `yarn run` command
Diffstat (limited to 'src')
-rw-r--r--src/_yarn18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/_yarn b/src/_yarn
index 9b96842..3689ae9 100644
--- a/src/_yarn
+++ b/src/_yarn
@@ -81,9 +81,21 @@ _yarn_commands_scripts() {
}
_yarn_scripts() {
- local -a scripts
- scripts=($(yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n' | sed -e 's/:/\\:/g'))
- _describe 'script' scripts
+ local -a commands binaries scripts
+ local -a scriptNames scriptCommands
+ local i runJSON
+
+ runJSON=$(yarn run --json 2>/dev/null)
+ binaries=($(sed -E '/Commands available/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\n/g' <<< "$runJSON"))
+ scriptNames=($(sed -E '/possibleCommands/!d;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\n/g' <<< "$runJSON"))
+ scriptCommands=("${(@f)$(sed -E '/possibleCommands/!d;s/.*"hints":\{([^}]+)\}.*/\1/;s/"[^"]+"://g;s/:/\\:/g;s/","/\n/g;s/(^"|"$)//g' <<< "$runJSON")}")
+
+ for (( i=1; i <= $#scriptNames; i++ )); do
+ scripts+=("${scriptNames[$i]}:${scriptCommands[$i]}")
+ done
+
+ commands=($scripts $binaries)
+ _describe 'command' commands
}
_yarn_global_commands() {