🔥 Remove test files after trashing.
This commit is contained in:
parent
a1f9032b95
commit
f24fc42362
@ -234,13 +234,27 @@ module Hbc
|
|||||||
|
|
||||||
ohai "Trashing files:"
|
ohai "Trashing files:"
|
||||||
puts resolved_paths.map(&:first)
|
puts resolved_paths.map(&:first)
|
||||||
@command.run!("/usr/bin/osascript", args: ["-e", <<-EOS.undent, *resolved_paths.flat_map(&:last)])
|
trash_paths(*resolved_paths.flat_map(&:last))
|
||||||
|
end
|
||||||
|
|
||||||
|
def trash_paths(*paths)
|
||||||
|
@command.run!("/usr/bin/osascript", args: ["-e", <<-'EOS'.undent, *paths])
|
||||||
on run argv
|
on run argv
|
||||||
repeat with i from 1 to (count argv)
|
repeat with i from 1 to (count argv)
|
||||||
set item i of argv to (item i of argv as POSIX file)
|
set item i of argv to (item i of argv as POSIX file)
|
||||||
end repeat
|
end repeat
|
||||||
|
|
||||||
tell application "Finder" to move argv to trash
|
tell application "Finder"
|
||||||
|
set trashedItems to (move argv to trash)
|
||||||
|
set output to ""
|
||||||
|
|
||||||
|
repeat with i from 1 to (count trashedItems)
|
||||||
|
set item i of trashedItems to POSIX path of (item i of trashedItems as string)
|
||||||
|
set output to output & (item i of trashedItems) & (do shell script "printf \"\\0\"")
|
||||||
|
end repeat
|
||||||
|
|
||||||
|
return output
|
||||||
|
end tell
|
||||||
end run
|
end run
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|||||||
@ -176,6 +176,14 @@ shared_examples "#uninstall_phase or #zap_phase" do
|
|||||||
let(:fake_system_command) { Hbc::NeverSudoSystemCommand }
|
let(:fake_system_command) { Hbc::NeverSudoSystemCommand }
|
||||||
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_name}-#{directive}.rb") }
|
let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-#{artifact_name}-#{directive}.rb") }
|
||||||
|
|
||||||
|
before(:each) do
|
||||||
|
allow_any_instance_of(Hbc::Artifact::UninstallBase).to receive(:trash_paths)
|
||||||
|
.and_wrap_original do |method, *args|
|
||||||
|
result = method.call(*args)
|
||||||
|
FileUtils.rm_rf result.stdout.split("\0")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "is supported" do
|
it "is supported" do
|
||||||
paths.each do |path|
|
paths.each do |path|
|
||||||
expect(path).to exist
|
expect(path).to exist
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user