mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 20:33:08 +00:00
Use jq
to iterate over installed dependencies for yarn
completions
Only if available, else fall back to fragile package.json parsing.
This commit is contained in:
parent
e48722f0bf
commit
5f82cb5ca4
1 changed files with 24 additions and 21 deletions
|
@ -38,7 +38,9 @@ function __yarn_installed_packages
|
|||
return 1
|
||||
end
|
||||
|
||||
# todo: if jq exists, use it instead and use what's below as a fallback only
|
||||
if type -q jq
|
||||
jq -r '.dependencies | to_entries[] | .key' bower.json
|
||||
else
|
||||
set -l depsFound 0
|
||||
for line in (cat $package_json)
|
||||
# echo "evaluating $line"
|
||||
|
@ -63,9 +65,10 @@ function __yarn_installed_packages
|
|||
string replace -r '^\s*"([^"]+)".*' '$1' -- $line
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
complete -f -c yarn -n '__fish_seen_subcommand_from remove' -a '(__yarn_installed_packages)'
|
||||
complete -f -c yarn -n '__fish_seen_subcommand_from remove' -xa '(__yarn_installed_packages)'
|
||||
complete -f -c yarn -n '__fish_seen_subcommand_from add' -a '(__yarn_filtered_list_packages)'
|
||||
|
||||
complete -f -c yarn -n '__fish_use_subcommand' -a help
|
||||
|
|
Loading…
Reference in a new issue