Skip to content

Commit

Permalink
fix overzealous cask already created error
Browse files Browse the repository at this point in the history
this prevented any cask being created via `brew cask create` that was a
suffix substring of an existing cask.

refs #998
  • Loading branch information
phinze committed Sep 9, 2013
1 parent cb4fd92 commit fbc246f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def self.path(cask_title)
if cask_title.include?('/')
cask_with_tap = cask_title
else
cask_with_tap = all_titles.grep(/#{cask_title}$/).first
cask_with_tap = all_titles.detect { |tap_and_title|
_, title = tap_and_title.split('/')
title == cask_title
}
end

if cask_with_tap
Expand Down
9 changes: 8 additions & 1 deletion test/cli/create_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module Cask::CLI::Create
before { Cask::CLI::Create.reset! }

after {
%w[ new-cask additional-cask another-cask ].each do |cask|
%w[ new-cask additional-cask another-cask feine ].each do |cask|
path = Cask.path(cask)
path.delete if path.exist?
end
Expand Down Expand Up @@ -61,4 +61,11 @@ class NewCask < Cask
Cask::CLI::Create.run('caffeine')
}.must_raise CaskAlreadyCreatedError
end

it 'allows creating casks that are substrings of existing casks' do
Cask::CLI::Create.run('feine')
Cask::CLI::Create.editor_commands.must_equal [
[Cask.path('feine')]
]
end
end

0 comments on commit fbc246f

Please sign in to comment.