Replace wildcard copy with a loop over children.
Fixes one of the errors in https://github.com/orgs/Homebrew/discussions/4498 (specifically "cp: [...].app/*: No such file or directory").
This commit is contained in:
parent
082017e93d
commit
2e8232de39
@ -94,9 +94,11 @@ module Cask
|
||||
if target.writable?
|
||||
source.children.each { |child| FileUtils.move(child, target + child.basename) }
|
||||
else
|
||||
command.run!("/bin/cp", args: ["-pR", "#{source}/*", "#{source}/.*", "#{target}/"],
|
||||
source.children.each do |child|
|
||||
command.run!("/bin/cp", args: ["-pR", child, target + child.basename],
|
||||
sudo: true)
|
||||
end
|
||||
end
|
||||
Quarantine.copy_xattrs(source, target)
|
||||
source.rmtree
|
||||
elsif target.dirname.writable?
|
||||
|
||||
@ -334,5 +334,26 @@ describe Cask::Artifact::App, :cask do
|
||||
|
||||
expect(contents_path).to exist
|
||||
end
|
||||
|
||||
it "properly handles non-writable directories" do
|
||||
install_phase
|
||||
|
||||
contents_path = target_path.join("Contents")
|
||||
|
||||
allow(target_path).to receive(:writable?).and_return false
|
||||
allow(command).to receive(:run!).and_call_original
|
||||
allow(command).to receive(:run!)
|
||||
.with("/bin/cp", args: ["-pR", source_path.join("Contents"), contents_path],
|
||||
sudo: true)
|
||||
.and_wrap_original do |original_method, *args, **kwargs|
|
||||
original_method.call(*args, sudo_as_root: false, **kwargs)
|
||||
end
|
||||
|
||||
app.uninstall_phase(command: command, force: force, successor: cask)
|
||||
expect(contents_path).not_to exist
|
||||
|
||||
app.install_phase(command: command, adopt: adopt, force: force, predecessor: cask)
|
||||
expect(contents_path).to exist
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user