From 2f54f2b21287a5753728feba1ae2abcbf9df2aab Mon Sep 17 00:00:00 2001 From: Shohei YOSHIDA Date: Wed, 8 Dec 2021 00:19:46 +0900 Subject: [PATCH] Support both older and newer versions --- src/_yarn | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/_yarn b/src/_yarn index b443e53..1e39837 100644 --- a/src/_yarn +++ b/src/_yarn @@ -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 }