Support both older and newer versions

This commit is contained in:
Shohei YOSHIDA 2021-12-08 00:19:46 +09:00
parent c6bce7358c
commit 2f54f2b212
No known key found for this signature in database
GPG Key ID: C9A1BB11BB940CF2
1 changed files with 7 additions and 1 deletions

View File

@ -137,7 +137,13 @@ _yarn_add_files() {
}
_yarn_workspaces() {
local -a workspaces=(${(@f)$(yarn workspaces list --json | sed -n 's|.*"name":"\([^"]*\)"}|\1|p')})
local version=$(yarn --version |sed -n 's|\([0-9]*\).*|\1|p')
local -a workspaces
if [[ $version == "1" ]]; then
workspaces=(${(@f)$(yarn workspaces info |sed -n -e 's/^ "\([^"]*\)": {/\1/p')})
else
workspaces=(${(@f)$(yarn workspaces list --json | sed -n 's|.*"name":"\([^"]*\)"}|\1|p')})
fi
_describe 'workspace' workspaces
}