ce298d090b737cbce2a87afaada2195b0bb2e801

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

yarn: use zsh-completions latest version (493984e)

Diff

 1diff --git a/plugins/yarn/_yarn b/plugins/yarn/_yarn
 2index 3689ae960d0e08af8a037cce3d95fafc78893377..70e783b864e26d4f78e3c2594c2270a06a9b34d0 100644
 3--- a/plugins/yarn/_yarn
 4+++ b/plugins/yarn/_yarn
 5@@ -86,9 +86,11 @@ _yarn_scripts() {
 6   local i runJSON
 7 
 8   runJSON=$(yarn run --json 2>/dev/null)
 9-  binaries=($(sed -E '/Commands available/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\n/g' <<< "$runJSON"))
10-  scriptNames=($(sed -E '/possibleCommands/!d;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\n/g' <<< "$runJSON"))
11-  scriptCommands=("${(@f)$(sed -E '/possibleCommands/!d;s/.*"hints":\{([^}]+)\}.*/\1/;s/"[^"]+"://g;s/:/\\:/g;s/","/\n/g;s/(^"|"$)//g' <<< "$runJSON")}")
12+  # Some sed utilities (e.g. Mac OS / BSD) don't interpret `\n` in a replacement
13+  # pattern as a newline. See https://superuser.com/q/307165
14+  binaries=($(sed -E '/Commands available/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON"))
15+  scriptNames=($(sed -E '/possibleCommands/!d;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON"))
16+  scriptCommands=("${(@f)$(sed -E '/possibleCommands/!d;s/.*"hints":\{(.+")\}.*/\1/;s/"[^"]+"://g;s/:/\\:/g;s/","/\'$'\n/g;s/(^"|"$)//g' <<< "$runJSON")}")
17 
18   for (( i=1; i <= $#scriptNames; i++ )); do
19     scripts+=("${scriptNames[$i]}:${scriptCommands[$i]}")