 0b6b2f04da
			
		
	
	
		0b6b2f04da
		
			
		
	
	
	
	
		
			
			- The `brew uninstall` command has `--zap`, so let's make `brew reinstall` have parity here for a better user experience. (Requested in issue 12983.) - It feels weird that to get my new reinstall test to pass I had to add `--zap` to `cask/cmd/install.rb`, not `cask/cmd/reinstall.rb` to get the tests to pass. But the `brew reinstall --cask caffeine --zap` command worked fine all the time. The CLI argument parser from the test run was complaining about not knowing what `zap` was. As a result, `--zap` now shows up as a switch in `brew install --help` which I'm not 100% convinced is the desired UX. But I've edited the description accordingly to specify that it will only work on `reinstall` operations (and `--zap` on `install` is a no-op). ``` issyl0 at pictor in /opt/homebrew on reinstall-cask-zap ❯ brew reinstall --cask caffeine --zap ==> Downloading https://github.com/IntelliScape/caffeine/releases/download/1.1.3/Caffeine.dmg Already downloaded: /Users/issyl0/Library/Caches/Homebrew/downloads/3d6ccfdd3b8d0ab37d1c2468d6e69078c2d31d3b12bf51947c4db21e5f376af2--Caffeine.dmg ==> Implied `brew uninstall --cask caffeine` ==> Backing App 'Caffeine.app' up to '/opt/homebrew/Caskroom/caffeine/1.1.3/Caffeine.app' ==> Removing App '/Applications/Caffeine.app' ==> Dispatching zap stanza ==> Trashing files: ~/Library/Application Support/com.intelliscapesolutions.caffeine ~/Library/Preferences/com.intelliscapesolutions.caffeine.plist ~/Library/Caches/com.intelliscapesolutions.caffeine ~/Library/HTTPStoages/com.intelliscapesolutions.caffeine.binarycookies ==> Removing all staged versions of Cask 'caffeine' ==> Installing Cask caffeine ==> Moving App 'Caffeine.app' to '/Applications/Caffeine.app' 🍺 caffeine was successfully installed! ```
		
			
				
	
	
		
			68 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| # typed: false
 | |
| # frozen_string_literal: true
 | |
| 
 | |
| describe Cask::Cmd::Reinstall, :cask do
 | |
|   it "displays the reinstallation progress" do
 | |
|     caffeine = Cask::CaskLoader.load(cask_path("local-caffeine"))
 | |
| 
 | |
|     Cask::Installer.new(caffeine).install
 | |
| 
 | |
|     output = Regexp.new <<~EOS
 | |
|       ==> Downloading file:.*caffeine.zip
 | |
|       Already downloaded: .*--caffeine.zip
 | |
|       ==> Uninstalling Cask local-caffeine
 | |
|       ==> Backing App 'Caffeine.app' up to '.*Caffeine.app'
 | |
|       ==> Removing App '.*Caffeine.app'
 | |
|       ==> Purging files for version 1.2.3 of Cask local-caffeine
 | |
|       ==> Installing Cask local-caffeine
 | |
|       ==> Moving App 'Caffeine.app' to '.*Caffeine.app'
 | |
|       .*local-caffeine was successfully installed!
 | |
|     EOS
 | |
| 
 | |
|     expect {
 | |
|       described_class.run("local-caffeine")
 | |
|     }.to output(output).to_stdout
 | |
|   end
 | |
| 
 | |
|   it "displays the reinstallation progress with zapping" do
 | |
|     caffeine = Cask::CaskLoader.load(cask_path("local-caffeine"))
 | |
| 
 | |
|     Cask::Installer.new(caffeine).install
 | |
| 
 | |
|     output = Regexp.new <<~EOS
 | |
|       ==> Downloading file:.*caffeine.zip
 | |
|       Already downloaded: .*--caffeine.zip
 | |
|       ==> Implied `brew uninstall --cask local-caffeine`
 | |
|       ==> Backing App 'Caffeine.app' up to '.*Caffeine.app'
 | |
|       ==> Removing App '.*Caffeine.app'
 | |
|       ==> Dispatching zap stanza
 | |
|       ==> Trashing files:
 | |
|       .*org\.example\.caffeine\.plist
 | |
|       ==> Removing all staged versions of Cask 'local-caffeine'
 | |
|       ==> Installing Cask local-caffeine
 | |
|       ==> Moving App 'Caffeine.app' to '.*Caffeine.app'
 | |
|       .*local-caffeine was successfully installed!
 | |
|     EOS
 | |
| 
 | |
|     expect {
 | |
|       described_class.run("local-caffeine", "--zap")
 | |
|     }.to output(output).to_stdout
 | |
|   end
 | |
| 
 | |
|   it "allows reinstalling a Cask" do
 | |
|     Cask::Cmd::Install.run("local-transmission")
 | |
| 
 | |
|     expect(Cask::CaskLoader.load(cask_path("local-transmission"))).to be_installed
 | |
| 
 | |
|     described_class.run("local-transmission")
 | |
|     expect(Cask::CaskLoader.load(cask_path("local-transmission"))).to be_installed
 | |
|   end
 | |
| 
 | |
|   it "allows reinstalling a non installed Cask" do
 | |
|     expect(Cask::CaskLoader.load(cask_path("local-transmission"))).not_to be_installed
 | |
| 
 | |
|     described_class.run("local-transmission")
 | |
|     expect(Cask::CaskLoader.load(cask_path("local-transmission"))).to be_installed
 | |
|   end
 | |
| end
 |