 97ad3567d1
			
		
	
	
		97ad3567d1
		
			
		
	
	
	
	
		
			
			- in `brew.sh` split the `case` into those cases that take a single or no arguments and those that take multiple arguments or handle multiple commands. This considerably speeds up the `brew shellenv bash` case that wasn't being handled here before. - add `setup-ruby` to the list of commands that can be called quickly by `brew.sh` without additional setup. This speeds up the `brew setup-ruby` no-op case by ~10x. - add a parameter to `setup-ruby` to avoid running Bundler if the command doesn't need it. This makes many more cases for `brew setup-ruby` to be no-op cases. - Remove the (now) unused `HOMEBREW_RUBY3` check in `setup-ruby`. - Improve argument handling in `command_path.sh` to allow it to be used as a function in `setup-ruby.sh`. - Add a new RuboCop to check usage of `install_bundler_gems!` is only inside `dev-cmd` (or a few other acceptable places). - Use new `processed_source.file_path` API in `formula_cop.rb`
		
			
				
	
	
		
			48 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
| # does the quickest output of brew command possible for the basic cases of an
 | |
| # official Bash or Ruby normal or dev-cmd command.
 | |
| # HOMEBREW_LIBRARY is set by brew.sh
 | |
| # shellcheck disable=SC2154
 | |
| homebrew-command-path() {
 | |
|   case "$1" in
 | |
|     # check we actually have command and not e.g. commandsomething
 | |
|     command) ;;
 | |
|     command*) return 1 ;;
 | |
|     *) ;;
 | |
|   esac
 | |
| 
 | |
|   local first_command found_command
 | |
|   for arg in "$@"
 | |
|   do
 | |
|     if [[ -z "${first_command}" && "${arg}" == "command" ]]
 | |
|     then
 | |
|       first_command=1
 | |
|       continue
 | |
|     elif [[ -f "${HOMEBREW_LIBRARY}/Homebrew/cmd/${arg}.sh" ]]
 | |
|     then
 | |
|       echo "${HOMEBREW_LIBRARY}/Homebrew/cmd/${arg}.sh"
 | |
|       found_command=1
 | |
|     elif [[ -f "${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${arg}.sh" ]]
 | |
|     then
 | |
|       echo "${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${arg}.sh"
 | |
|       found_command=1
 | |
|     elif [[ -f "${HOMEBREW_LIBRARY}/Homebrew/cmd/${arg}.rb" ]]
 | |
|     then
 | |
|       echo "${HOMEBREW_LIBRARY}/Homebrew/cmd/${arg}.rb"
 | |
|       found_command=1
 | |
|     elif [[ -f "${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${arg}.rb" ]]
 | |
|     then
 | |
|       echo "${HOMEBREW_LIBRARY}/Homebrew/dev-cmd/${arg}.rb"
 | |
|       found_command=1
 | |
|     else
 | |
|       return 1
 | |
|     fi
 | |
|   done
 | |
| 
 | |
|   if [[ -n "${found_command}" ]]
 | |
|   then
 | |
|     return 0
 | |
|   else
 | |
|     return 1
 | |
|   fi
 | |
| }
 |