Merge pull request #653 from MaximDevoir/feat/improve-yarn-suggestions
YARN | Improve suggestions for `yarn run` command
This commit is contained in:
commit
87e131334f
18
src/_yarn
18
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() {
|
||||
|
|
Loading…
Reference in New Issue