Merge pull request #8370 from miccal/cask_symlinked
cask/artifact/symlinked: do not overwrite files or symbolic links
This commit is contained in:
commit
15279d78b7
@ -44,10 +44,10 @@ module Cask
|
|||||||
"source '#{source}' is not there."
|
"source '#{source}' is not there."
|
||||||
end
|
end
|
||||||
|
|
||||||
if target.exist? && !target.symlink?
|
if target.exist?
|
||||||
raise CaskError,
|
raise CaskError,
|
||||||
"It seems there is already #{self.class.english_article} " \
|
"It seems there already exists #{self.class.english_article} " \
|
||||||
"#{self.class.english_name} at '#{target}'; not linking."
|
"#{self.class.english_name} at '#{target}'; not overwriting."
|
||||||
end
|
end
|
||||||
|
|
||||||
ohai "Linking #{self.class.english_name} '#{source.basename}' to '#{target}'."
|
ohai "Linking #{self.class.english_name} '#{source.basename}' to '#{target}'."
|
||||||
|
|||||||
@ -67,14 +67,16 @@ describe Cask::Artifact::Binary, :cask do
|
|||||||
expect(expected_path).not_to be :symlink?
|
expect(expected_path).not_to be :symlink?
|
||||||
end
|
end
|
||||||
|
|
||||||
it "clobbers an existing symlink" do
|
it "avoids clobbering an existing symlink" do
|
||||||
expected_path.make_symlink("/tmp")
|
expected_path.make_symlink("/tmp")
|
||||||
|
|
||||||
|
expect {
|
||||||
artifacts.each do |artifact|
|
artifacts.each do |artifact|
|
||||||
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
|
||||||
end
|
end
|
||||||
|
}.to raise_error(Cask::CaskError)
|
||||||
|
|
||||||
expect(File.readlink(expected_path)).not_to eq("/tmp")
|
expect(File.readlink(expected_path)).to eq("/tmp")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates parent directory if it doesn't exist" do
|
it "creates parent directory if it doesn't exist" do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user