-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add fish completion for yarn workspaces
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{}: | ||
|
||
{ | ||
xdg.configFile.fishCompletionYarn = { | ||
executable = true; | ||
target = "fish/completions/yarn.fish"; | ||
text = '' | ||
function __fish_yarn_get_workspaces | ||
if type -q jq && test -f package.json | ||
command \ | ||
# List all workspaces glob patterns in the current workspaces | ||
jq -r '.workspaces | .[]' package.json 2>/dev/null |\ | ||
# list nested package.json files in every glob pattern | ||
xargs -I {} -- fish -c "ls {}/package.json 2>/dev/null" |\ | ||
# get name of the workspace from the package.json | ||
xargs -I {} -- fish -c "jq -r '.name' {} 2>/dev/null" |\ | ||
# remove empty lines | ||
grep -v '^$' 2>/dev/null |\ | ||
# remove duplicates | ||
sort -u 2>/dev/null | ||
end | ||
end | ||
complete -f -c yarn -n '__fish_seen_subcommand_from workspace' -a "(__fish_yarn_get_workspaces)" | ||
''; | ||
}; | ||
} |