aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorL. E. Segovia2017-10-27 16:53:22 -0300
committerL. E. Segovia2017-10-28 20:36:41 -0300
commit809e82038894da86a49f634e2b798db21e09a852 (patch)
tree94fe3e26a1cb33cb0c14c15cb2c48538d650a2bd /Library
parent7caca570736a6232512328992b398270dbbf3f4f (diff)
downloadbrew-809e82038894da86a49f634e2b798db21e09a852.tar.bz2
Check that a single uninstall_* and zap stanzas is defined
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc/audit.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb
index 5180c5688..e4349dc2d 100644
--- a/Library/Homebrew/cask/lib/hbc/audit.rb
+++ b/Library/Homebrew/cask/lib/hbc/audit.rb
@@ -31,6 +31,7 @@ module Hbc
check_generic_artifacts
check_token_conflicts
check_download
+ check_single_uninstall_zap
self
rescue StandardError => e
odebug "#{e.message}\n#{e.backtrace.join("\n")}"
@@ -48,6 +49,22 @@ module Hbc
private
+ def check_single_uninstall_zap
+ odebug "Auditing single uninstall_* and zap stanzas"
+
+ uninstalls = cask.artifacts.find_all { |k| k.is_a?(Hbc::Artifact::Uninstall) }
+ add_warning "there should be a single uninstall stanza" unless uninstalls.size <= 1
+
+ uninstalls_preflight = cask.artifacts.find_all { |k| k.is_a?(Hbc::Artifact::PreflightBlock) && k.directives.keys.include?("uninstall_preflight") }
+ add_warning "there should be a single uninstall_preflight stanza" unless uninstalls_preflight.size <= 1
+
+ uninstalls_postflight = cask.artifacts.find_all { |k| k.is_a?(Hbc::Artifact::PostflightBlock) && k.directives.keys.include?("uninstall_postflight") }
+ add_warning "there should be a single uninstall_postflight stanza" unless uninstalls_postflight.size <= 1
+
+ zaps = cask.artifacts.find_all { |k| k.is_a?(Hbc::Artifact::Zap) }
+ add_warning "there should be a single zap stanza" unless zaps.size <= 1
+ end
+
def check_required_stanzas
odebug "Auditing required stanzas"
[:version, :sha256, :url, :homepage].each do |sym|