diff options
| author | nicoulaj <julien.nicoulaud@gmail.com> | 2019-10-08 18:54:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-08 18:54:55 +0200 |
| commit | 87e131334fbb08e1622eff5cf27efead23875c4f (patch) | |
| tree | 80f117e58de28dad05f213f72783926dfd1cb142 /src | |
| parent | Merge pull request #654 from bondz/patch-1 (diff) | |
| parent | revert: suggest binaries on `yarn` (diff) | |
| download | zsh-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/_yarn | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -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() { |
