Skip to content
Snippets Groups Projects
Unverified Commit 15279d78 authored by Markus Reiter's avatar Markus Reiter Committed by GitHub
Browse files

Merge pull request #8370 from miccal/cask_symlinked

cask/artifact/symlinked: do not overwrite files or symbolic links
parents ded29277 5a74f1d9
No related branches found
No related tags found
No related merge requests found
......@@ -44,10 +44,10 @@ module Cask
"source '#{source}' is not there."
end
if target.exist? && !target.symlink?
if target.exist?
raise CaskError,
"It seems there is already #{self.class.english_article} " \
"#{self.class.english_name} at '#{target}'; not linking."
"It seems there already exists #{self.class.english_article} " \
"#{self.class.english_name} at '#{target}'; not overwriting."
end
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?
end
it "clobbers an existing symlink" do
it "avoids clobbering an existing symlink" do
expected_path.make_symlink("/tmp")
artifacts.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
end
expect {
artifacts.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
end
}.to raise_error(Cask::CaskError)
expect(File.readlink(expected_path)).not_to eq("/tmp")
expect(File.readlink(expected_path)).to eq("/tmp")
end
it "creates parent directory if it doesn't exist" do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment