cask "powershell@preview" do arch arm: "arm64", intel: "x64" version "7.6.0-preview.4" sha256 arm: "78065c18a070bfb0d16aa97c47e1a72060457e48d72afa031389fc12a465e0d5", intel: "8c93097b6a9b1b27db2f2a999fabf12df9daf9b226bc786e67b5819a213da633" url "https://github.com/PowerShell/PowerShell/releases/download/v#{version}/powershell-#{version}-osx-#{arch}.pkg" name "PowerShell" desc "Command-line shell and scripting language" homepage "https://github.com/PowerShell/PowerShell" # There can be a notable gap between when a version is tagged and a # corresponding release is created, so we check releases instead of the Git # tags. Unstable versions are correctly marked as "pre-release" on GitHub, so # we have to use the `GithubReleases` strategy to identify unstable releases. livecheck do url :url regex(/^v?(\d+(?:\.\d+)+[_-](?:preview|rc)(?:\.\d+)?)$/i) strategy :github_releases do |json, regex| json.map do |release| next if release["draft"] match = release["tag_name"]&.match(regex) next if match.blank? match[1] end end end depends_on macos: ">= :mojave" pkg "powershell-#{version}-osx-#{arch}.pkg" uninstall pkgutil: "com.microsoft.powershell-preview" zap trash: [ "~/.cache/powershell", "~/.config/PowerShell", "~/.local/share/powershell", ], rmdir: [ "~/.cache", "~/.config", "~/.local", "~/.local/share", ] caveats <<~EOS To use Homebrew in PowerShell, set: Add-Content -Path $PROFILE.CurrentUserAllHosts -Value '$(#{HOMEBREW_PREFIX}/bin/brew shellenv) | Invoke-Expression' EOS end