Merge pull request #10956 from cho-m/cask-uninstall-script-tilde
cask uninstall script: allow tilde expansion to '$HOME'
This commit is contained in:
commit
bcd83fa5e3
@ -30,6 +30,7 @@ module Cask
|
|||||||
|
|
||||||
def staged_path_join_executable(path)
|
def staged_path_join_executable(path)
|
||||||
path = Pathname(path)
|
path = Pathname(path)
|
||||||
|
path = path.expand_path if path.to_s.start_with?("~")
|
||||||
|
|
||||||
absolute_path = if path.absolute?
|
absolute_path = if path.absolute?
|
||||||
path
|
path
|
||||||
|
|||||||
@ -90,6 +90,30 @@ describe Cask::Cmd::Uninstall, :cask do
|
|||||||
expect(cask).not_to be_installed
|
expect(cask).not_to be_installed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when Casks use script path with `~` as `HOME`" do
|
||||||
|
let(:home_dir) { mktmpdir }
|
||||||
|
let(:app) { Pathname.new("#{home_dir}/MyFancyApp.app") }
|
||||||
|
let(:cask) { Cask::CaskLoader.load(cask_path("with-uninstall-script-user-relative")) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
ENV["HOME"] = home_dir
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can still uninstall them" do
|
||||||
|
Cask::Installer.new(cask).install
|
||||||
|
|
||||||
|
expect(cask).to be_installed
|
||||||
|
expect(app).to exist
|
||||||
|
|
||||||
|
expect {
|
||||||
|
described_class.run("with-uninstall-script-user-relative")
|
||||||
|
}.not_to raise_error
|
||||||
|
|
||||||
|
expect(cask).not_to be_installed
|
||||||
|
expect(app).not_to exist
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "when multiple versions of a cask are installed" do
|
describe "when multiple versions of a cask are installed" do
|
||||||
let(:token) { "versioned-cask" }
|
let(:token) { "versioned-cask" }
|
||||||
let(:first_installed_version) { "1.2.3" }
|
let(:first_installed_version) { "1.2.3" }
|
||||||
|
|||||||
@ -0,0 +1,21 @@
|
|||||||
|
cask "with-uninstall-script-user-relative" do
|
||||||
|
version "1.2.3"
|
||||||
|
sha256 "5633c3a0f2e572cbf021507dec78c50998b398c343232bdfc7e26221d0a5db4d"
|
||||||
|
|
||||||
|
url "file://#{TEST_FIXTURE_DIR}/cask/MyFancyApp.zip"
|
||||||
|
homepage "https://brew.sh/MyFancyApp"
|
||||||
|
|
||||||
|
app "MyFancyApp/MyFancyApp.app", target: "~/MyFancyApp.app"
|
||||||
|
|
||||||
|
postflight do
|
||||||
|
IO.write "#{ENV["HOME"]}/MyFancyApp.app/uninstall.sh", <<~SH
|
||||||
|
#!/bin/sh
|
||||||
|
/bin/rm -r "#{ENV["HOME"]}/MyFancyApp.app"
|
||||||
|
SH
|
||||||
|
end
|
||||||
|
|
||||||
|
uninstall script: {
|
||||||
|
executable: "~/MyFancyApp.app/uninstall.sh",
|
||||||
|
sudo: false,
|
||||||
|
}
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user