dev-cmd/livecheck: respect --cask and --formula
When running `brew livecheck --cask` or `brew livecheck --formula`, livecheck wasn't properly respecting these flags. It should have worked by only including the casks or formulae in the watchlist but instead these flags were treating all the names in the watchlist as formulae or casks, which doesn't work properly. This addresses the issue by always using `#to_formulae_and_casks` on the watchlist names and then using `#reject` to conditionally exclude formulae or casks based on whether the related flags were passed to `brew livecheck`.
This commit is contained in:
		
							parent
							
								
									b041f76ee9
								
							
						
					
					
						commit
						15a868c5e6
					
				@ -86,13 +86,11 @@ module Homebrew
 | 
			
		||||
        names = Pathname.new(WATCHLIST_PATH).read.lines
 | 
			
		||||
                        .reject { |line| line.start_with?("#") || line.blank? }
 | 
			
		||||
                        .map(&:strip)
 | 
			
		||||
 | 
			
		||||
        named_args = T.unsafe(CLI::NamedArgs).new(*names)
 | 
			
		||||
        if args.formula?
 | 
			
		||||
          named_args.to_formulae
 | 
			
		||||
        elsif args.cask?
 | 
			
		||||
          named_args.to_casks
 | 
			
		||||
        else
 | 
			
		||||
          named_args.to_formulae_and_casks
 | 
			
		||||
        named_args.to_formulae_and_casks.reject do |formula_or_cask|
 | 
			
		||||
          (args.formula? && !formula_or_cask.is_a?(Formula)) ||
 | 
			
		||||
            (args.cask? && !formula_or_cask.is_a?(Cask::Cask))
 | 
			
		||||
        end
 | 
			
		||||
      rescue Errno::ENOENT => e
 | 
			
		||||
        onoe e
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user