Skip to content

Commit

Permalink
fix: user yarn default completion when possible
Browse files Browse the repository at this point in the history
This will keep the completion up to date, and sharpen focus of this
tool: only add better completion, don't remove existing completion!

Fixes #7
  • Loading branch information
BuonOmo committed Nov 7, 2022
1 parent abc052f commit 7850254
Showing 1 changed file with 3 additions and 35 deletions.
38 changes: 3 additions & 35 deletions yarn-completion.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -101,43 +101,9 @@ _yc_yarn_run_completion() {
_describe 'values' options
}

_yc_yarn_commands_completion() {
_values \
'subcommand' \
'add[Installs a package and any packages that it depends on.]' \
'bin[Displays the location of the yarn bin folder.]' \
'cache[Yarn stores every package in a global cache in your user directory on the file system.]' \
'check[Verifies that versions of the package.]' \
'clean[Cleans and removes unnecessary files from package dependencies.]' \
'config[Manages the yarn configuration files.]' \
'generate-lock-entry[Generates a lock file entry.]' \
'global[Install packages globally on your operating system.]' \
'info[Show information about a package.]' \
'init[Interactively creates or updates a package.json file.]' \
'install[Install packages]' \
'licenses[List licenses for installed packages.]' \
'link[Symlink a package folder during development.]' \
'login[Store registry username and email.]' \
'logout[Clear registry username and email.]' \
'ls[List installed packages.]' \
'outdated[Checks for outdated package dependencies.]' \
'owner[Manage package owners.]' \
'pack[Creates a compressed gzip archive of package dependencies.]' \
'publish[Publishes a package to the npm registry.]' \
'remove[Remove package and update package.json and yarn.lock ]' \
'run[Runs a defined package script.]' \
'self-update[Updates Yarn to the latest version.]' \
'tag[Add, remove, or list tags on a package.]' \
'team[Maintain team memberships]' \
'unlink[Unlink a previously created symlink for a package.]' \
'upgrade[Upgrades packages to their latest version based on the specified range.]' \
'version[Updates the package version.]' \
'why[Show information about why a package is installed.]'
}

_yc_zsh_better_yarn_completion() {
# Show yarn commands if not typed yet
[[ $(_yc_no_of_yarn_args) -le 2 ]] && _yc_yarn_commands_completion && return
[[ $(_yc_no_of_yarn_args) -le 2 ]] && _yarn "$@" && return

# Load custom completion commands
case "$(_yc_yarn_command)" in
Expand All @@ -150,6 +116,8 @@ _yc_zsh_better_yarn_completion() {
run)
_yc_yarn_run_completion
;;
*)
_yarn "$@"
esac
}

Expand Down

0 comments on commit 7850254

Please sign in to comment.