aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib
diff options
context:
space:
mode:
authorMarkus Reiter2017-11-03 13:23:08 +0100
committerGitHub2017-11-03 13:23:08 +0100
commit4eeac6f884a72bd16ddbab03db22f293e18f02bc (patch)
treeea452fbb6bbce34c08176f59987cdaf93a2cf0e8 /Library/Homebrew/cask/lib
parent0ac55875c5bd80687e7418995d6d9a485a8c032f (diff)
parenteaae7f3a5b7dcce0d6c4a3238547996e886b7144 (diff)
downloadbrew-4eeac6f884a72bd16ddbab03db22f293e18f02bc.tar.bz2
Merge pull request #3389 from amyspark/hacktoberfest-single-zap
Check that a single uninstall_* and zap stanza is defined
Diffstat (limited to 'Library/Homebrew/cask/lib')
-rw-r--r--Library/Homebrew/cask/lib/hbc/audit.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb
index 5180c5688..d757b0623 100644
--- a/Library/Homebrew/cask/lib/hbc/audit.rb
+++ b/Library/Homebrew/cask/lib/hbc/audit.rb
@@ -31,6 +31,8 @@ module Hbc
check_generic_artifacts
check_token_conflicts
check_download
+ check_single_pre_postflight
+ check_single_uninstall_zap
self
rescue StandardError => e
odebug "#{e.message}\n#{e.backtrace.join("\n")}"
@@ -48,6 +50,36 @@ module Hbc
private
+ def check_single_pre_postflight
+ odebug "Auditing preflight and postflight stanzas"
+
+ if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PreflightBlock) && k.directives.key?(:preflight) } > 1
+ add_warning "only a single preflight stanza is allowed"
+ end
+
+ return unless cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PostflightBlock) && k.directives.key?(:postflight) } > 1
+ add_warning "only a single postflight stanza is allowed"
+ end
+
+ def check_single_uninstall_zap
+ odebug "Auditing single uninstall_* and zap stanzas"
+
+ if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::Uninstall) } > 1
+ add_warning "only a single uninstall stanza is allowed"
+ end
+
+ if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PreflightBlock) && k.directives.key?(:uninstall_preflight) } > 1
+ add_warning "only a single uninstall_preflight stanza is allowed"
+ end
+
+ if cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::PostflightBlock) && k.directives.key?(:uninstall_postflight) } > 1
+ add_warning "only a single uninstall_postflight stanza is allowed"
+ end
+
+ return unless cask.artifacts.count { |k| k.is_a?(Hbc::Artifact::Zap) } > 1
+ add_warning "only a single zap stanza is allowed"
+ end
+
def check_required_stanzas
odebug "Auditing required stanzas"
[:version, :sha256, :url, :homepage].each do |sym|