parent
ec6d0a1ab9
commit
6aeccd1283
|
@ -63,12 +63,11 @@ module Service
|
|||
|
||||
# Whether the service should be launched at startup
|
||||
def service_startup?
|
||||
if service?
|
||||
@service_startup ||= load_service.requires_root?
|
||||
return @service_startup
|
||||
@service_startup ||= if service?
|
||||
load_service.requires_root?
|
||||
else
|
||||
false
|
||||
end
|
||||
|
||||
@service_startup ||= formula.plist_startup.present?
|
||||
end
|
||||
|
||||
# Path to destination service directory. If run as root, it's `boot_path`, else `user_path`.
|
||||
|
@ -86,12 +85,11 @@ module Service
|
|||
formula.any_version_installed?
|
||||
end
|
||||
|
||||
# Returns `true` if the formula implements #plist or the plist file exists.
|
||||
# Returns `true` if the plist file exists.
|
||||
def plist?
|
||||
return false unless installed?
|
||||
return true if service_file.file?
|
||||
return true unless formula.plist.nil?
|
||||
return false unless formula.opt_prefix.exist?
|
||||
return false unless formula.opt_prefix&.exist?
|
||||
return true if Keg.for(formula.opt_prefix).plist_installed?
|
||||
|
||||
false
|
||||
|
|
|
@ -11,7 +11,7 @@ module Service
|
|||
|
||||
formulae = Formula.installed
|
||||
.map { |formula| FormulaWrapper.new(formula) }
|
||||
.select { |formula| formula.service? || formula.plist? }
|
||||
.select(&:service?)
|
||||
.sort_by(&:name)
|
||||
|
||||
formulae = formulae.select { |formula| formula.loaded? == loaded } unless loaded.nil?
|
||||
|
|
|
@ -102,7 +102,7 @@ module Service
|
|||
|
||||
odie "Formula `#{service.name}` is not installed." unless service.installed?
|
||||
|
||||
file ||= if service.service_file.exist? || System.systemctl? || service.formula.plist.blank?
|
||||
file ||= if service.service_file.exist? || System.systemctl?
|
||||
nil
|
||||
elsif service.formula.opt_prefix.exist? && (keg = Keg.for service.formula.opt_prefix) && keg.plist_installed?
|
||||
service_file = Dir["#{keg}/*#{service.service_file.extname}"].first
|
||||
|
|
|
@ -135,13 +135,6 @@ describe Service::FormulaWrapper do
|
|||
File.delete(tempfile)
|
||||
end
|
||||
|
||||
it "true if plist" do
|
||||
allow(service).to receive_messages(installed?: true,
|
||||
service_file: Pathname.new("/dev/null"),
|
||||
formula: OpenStruct.new(plist: "a"))
|
||||
expect(service.plist?).to be(true)
|
||||
end
|
||||
|
||||
it "false if opt_prefix missing" do
|
||||
allow(service).to receive_messages(installed?: true,
|
||||
service_file: Pathname.new("/dev/null"),
|
||||
|
@ -297,17 +290,6 @@ describe Service::FormulaWrapper do
|
|||
|
||||
expect(service.service_startup?).to be(true)
|
||||
end
|
||||
|
||||
it "outputs true since there is a startup plist" do
|
||||
allow(described_class).to receive(:service?).and_return(false)
|
||||
formula = OpenStruct.new(
|
||||
plist_startup: true,
|
||||
)
|
||||
|
||||
service = described_class.new(formula)
|
||||
|
||||
expect(service.service_startup?).to be(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#to_hash" do
|
||||
|
|
Loading…
Reference in New Issue