Fix run subcommand --cwd issue
opt_args cannot be read from 2nd completion
This commit is contained in:
		
							parent
							
								
									bb8d024b65
								
							
						
					
					
						commit
						fd64c85cf7
					
				
							
								
								
									
										11
									
								
								src/_yarn
								
								
								
								
							
							
						
						
									
										11
									
								
								src/_yarn
								
								
								
								
							|  | @ -36,6 +36,8 @@ | ||||||
| # | # | ||||||
| # ------------------------------------------------------------------------------ | # ------------------------------------------------------------------------------ | ||||||
| 
 | 
 | ||||||
|  | declare -g _yarn_run_cwd | ||||||
|  | 
 | ||||||
| _commands=( | _commands=( | ||||||
|   'access' |   'access' | ||||||
|   'audit:Checks for known security issues with the installed packages' |   'audit:Checks for known security issues with the installed packages' | ||||||
|  | @ -99,8 +101,8 @@ _yarn_scripts() { | ||||||
|   local -a scriptNames scriptCommands |   local -a scriptNames scriptCommands | ||||||
|   local i runJSON |   local i runJSON | ||||||
| 
 | 
 | ||||||
|   if [[ -n $opt_args[--cwd] ]]; then |   if [[ -n $_yarn_run_cwd ]]; then | ||||||
|     runJSON=$(cd $opt_args[--cwd] && yarn run --json 2>/dev/null) |     runJSON=$(cd $_yarn_run_cwd && yarn run --json 2>/dev/null) | ||||||
|   else |   else | ||||||
|     runJSON=$(yarn run --json 2>/dev/null) |     runJSON=$(yarn run --json 2>/dev/null) | ||||||
|   fi |   fi | ||||||
|  | @ -313,6 +315,11 @@ _yarn() { | ||||||
|         ;; |         ;; | ||||||
| 
 | 
 | ||||||
|         run) |         run) | ||||||
|  |           if [[ -n $opt_args[--cwd] ]]; then | ||||||
|  |             _yarn_run_cwd=$opt_args[--cwd] | ||||||
|  |           else | ||||||
|  |             _yarn_run_cwd='' | ||||||
|  |           fi | ||||||
|           _arguments \ |           _arguments \ | ||||||
|             '1: :_yarn_scripts' \ |             '1: :_yarn_scripts' \ | ||||||
|             '*:: :_default' |             '*:: :_default' | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue