Skip to content

feat: yarn version berry workspace autocompletion#54

Open
devthejo wants to merge 1 commit into
dsifford:masterfrom
devthejo:master
Open

feat: yarn version berry workspace autocompletion#54
devthejo wants to merge 1 commit into
dsifford:masterfrom
devthejo:master

Conversation

@devthejo
Copy link
Copy Markdown

@devthejo devthejo commented Apr 3, 2022

Hello @dsifford ,
first I want to thank you for this great autocompletion script,
I use yarn berry version (v2/v3) and the completion work for most of commands except for yarn workspace, this PR solve this, detecting yarn v2/v3 and use correct completion command for workspaces adressing this issue and makin my life easier ;):
#49

@devthejo devthejo mentioned this pull request Apr 3, 2022
Copy link
Copy Markdown
Owner

@dsifford dsifford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! This looks pretty good, except that it will not work under certain circumstances. See comments for explanation.

Comment thread yarn-completion.bash
sed -n 's/^ \{2\}"\([^"]*\)": {$/\1/p' <<< "$workspaces_info"
)
COMPREPLY=($(compgen -W "${MAPFILE[*]}" -- "$cur"))
if [ -f .yarnrc.yml ]; then
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only work properly if you are completing yarn from the root of the project. If you call yarn workspace <Tab> from any child directories, this will fail.

See the following snippet for how the script locates the package.json file.

while [[ -n $cwd ]]; do
if [[ -f "$cwd/package.json" ]]; then
package_dot_json="$cwd/package.json"
break
fi
cwd="${cwd%/*}"
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants