Fix uninstall with :signal.
This commit is contained in:
parent
f3ec40d696
commit
76cb1462d4
@ -28,6 +28,7 @@ module Hbc
|
|||||||
|
|
||||||
def initialize(cask, directives)
|
def initialize(cask, directives)
|
||||||
super(cask)
|
super(cask)
|
||||||
|
directives[:signal] = [*directives[:signal]].flatten.each_slice(2).to_a
|
||||||
@directives = directives
|
@directives = directives
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -35,6 +36,10 @@ module Hbc
|
|||||||
directives.to_h
|
directives.to_h
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def summarize
|
||||||
|
to_h.map { |key, val| [*val].map { |v| "#{key.inspect} => #{v.inspect}" }.join(", ") }.join(", ")
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def dispatch_uninstall_directives(**options)
|
def dispatch_uninstall_directives(**options)
|
||||||
@ -122,15 +127,15 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
# :signal should come after :quit so it can be used as a backup when :quit fails
|
# :signal should come after :quit so it can be used as a backup when :quit fails
|
||||||
def uninstall_signal(*signals, **options)
|
def uninstall_signal(*signals, command: nil, **_)
|
||||||
signals.flatten.each_slice(2) do |pair|
|
signals.each do |pair|
|
||||||
unless pair.size == 2
|
unless pair.size == 2
|
||||||
raise CaskInvalidError.new(cask, "Each #{stanza} :signal must consist of 2 elements.")
|
raise CaskInvalidError.new(cask, "Each #{stanza} :signal must consist of 2 elements.")
|
||||||
end
|
end
|
||||||
|
|
||||||
signal, bundle_id = pair
|
signal, bundle_id = pair
|
||||||
ohai "Signalling '#{signal}' to application ID '#{bundle_id}'"
|
ohai "Signalling '#{signal}' to application ID '#{bundle_id}'"
|
||||||
pids = running_processes(bundle_id, **options).map(&:first)
|
pids = running_processes(bundle_id, command: command).map(&:first)
|
||||||
next unless pids.any?
|
next unless pids.any?
|
||||||
# Note that unlike :quit, signals are sent from the current user (not
|
# Note that unlike :quit, signals are sent from the current user (not
|
||||||
# upgraded to the superuser). This is a todo item for the future, but
|
# upgraded to the superuser). This is a todo item for the future, but
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user