Skip to content

Commit

Permalink
Merge pull request #4928 from rolandwalker/unininstall_trash_delete
Browse files Browse the repository at this point in the history
DSL: add uninstall `:delete` and `:trash`
  • Loading branch information
rolandwalker committed Jul 2, 2014
2 parents 3932c4d + 4c6e5e2 commit ea27fb8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/cask/artifact/uninstall_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def dispatch_uninstall_directives(stanza)
ohai "Running #{stanza} process for #{@cask}; your password may be necessary"

directives_set.each do |directives|
unknown_keys = directives.keys - [:early_script, :launchctl, :quit, :signal, :kext, :script, :pkgutil, :files]
unknown_keys = directives.keys - [:early_script, :launchctl, :quit, :signal, :kext, :script, :pkgutil, :files, :delete, :trash]
unless unknown_keys.empty?
opoo %Q{Unknown arguments to #{stanza} -- #{unknown_keys.inspect}. Running "brew update && brew upgrade brew-cask && brew cleanup && brew cask cleanup" will likely fix it.}
end
Expand Down Expand Up @@ -122,6 +122,23 @@ def dispatch_uninstall_directives(stanza)
end
end

directives_set.select{ |h| h.key?(:delete) }.each do |directives|
Array(directives[:delete]).flatten.each_slice(500) do |file_slice|
ohai "Removing files: #{file_slice.utf8_inspect}"
@command.run!('/bin/rm', :args => file_slice.unshift('-rf', '--'), :sudo => true)
end
end

# :trash functionality is stubbed as a synonym for :delete
# todo: make :trash work differently, moving files to the Trash
directives_set.select{ |h| h.key?(:trash) }.each do |directives|
Array(directives[:trash]).flatten.each_slice(500) do |file_slice|
ohai "Removing files: #{file_slice.utf8_inspect}"
@command.run!('/bin/rm', :args => file_slice.unshift('-rf', '--'), :sudo => true)
end
end

# todo: remove support for deprecated :files both here and elsewhere
directives_set.select{ |h| h.key?(:files) }.each do |directives|
Array(directives[:files]).flatten.each_slice(500) do |file_slice|
ohai "Removing files: #{file_slice.utf8_inspect}"
Expand Down

0 comments on commit ea27fb8

Please sign in to comment.