Merge pull request #11298 from SMillerDev/feature/service/plist_options
services: replace plist_options :manual with service command
This commit is contained in:
commit
1de2b234b2
@ -152,13 +152,19 @@ class Caveats
|
|||||||
end
|
end
|
||||||
|
|
||||||
def plist_caveats
|
def plist_caveats
|
||||||
return unless f.plist_manual
|
return if !f.plist_manual && !f.service?
|
||||||
|
|
||||||
|
command = if f.service?
|
||||||
|
f.service.command.join(" ")
|
||||||
|
else
|
||||||
|
f.plist_manual
|
||||||
|
end
|
||||||
|
|
||||||
# Default to brew services not being supported. macOS overrides this behavior.
|
# Default to brew services not being supported. macOS overrides this behavior.
|
||||||
<<~EOS
|
<<~EOS
|
||||||
#{Formatter.warning("Warning:")} #{f.name} provides a launchd plist which can only be used on macOS!
|
#{Formatter.warning("Warning:")} #{f.name} provides a launchd plist which can only be used on macOS!
|
||||||
You can manually execute the service instead with:
|
You can manually execute the service instead with:
|
||||||
#{f.plist_manual}
|
#{command}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,14 +6,15 @@ class Caveats
|
|||||||
|
|
||||||
def plist_caveats
|
def plist_caveats
|
||||||
s = []
|
s = []
|
||||||
if f.plist || keg&.plist_installed?
|
return if !f.plist && !f.service? && !keg&.plist_installed?
|
||||||
|
|
||||||
plist_domain = f.plist_path.basename(".plist")
|
plist_domain = f.plist_path.basename(".plist")
|
||||||
|
|
||||||
# we readlink because this path probably doesn't exist since caveats
|
# we readlink because this path probably doesn't exist since caveats
|
||||||
# occurs before the link step of installation
|
# occurs before the link step of installation
|
||||||
# Yosemite security measures mildly tighter rules:
|
# Yosemite security measures mildly tighter rules:
|
||||||
# https://github.com/Homebrew/legacy-homebrew/issues/33815
|
# https://github.com/Homebrew/legacy-homebrew/issues/33815
|
||||||
if !plist_path.file? || !plist_path.symlink?
|
if f.plist && (!plist_path.file? || !plist_path.symlink?)
|
||||||
if f.plist_startup
|
if f.plist_startup
|
||||||
s << "To have launchd start #{f.full_name} now and restart at startup:"
|
s << "To have launchd start #{f.full_name} now and restart at startup:"
|
||||||
s << " sudo brew services start #{f.full_name}"
|
s << " sudo brew services start #{f.full_name}"
|
||||||
@ -34,9 +35,15 @@ class Caveats
|
|||||||
s << " brew services start #{f.full_name}"
|
s << " brew services start #{f.full_name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if f.plist_manual
|
if f.plist_manual || f.service?
|
||||||
|
command = if f.service?
|
||||||
|
f.service.command.join(" ")
|
||||||
|
else
|
||||||
|
f.plist_manual
|
||||||
|
end
|
||||||
|
|
||||||
s << "Or, if you don't want/need a background service you can just run:"
|
s << "Or, if you don't want/need a background service you can just run:"
|
||||||
s << " #{f.plist_manual}"
|
s << " #{command}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# pbpaste is the system clipboard tool on macOS and fails with `tmux` by default
|
# pbpaste is the system clipboard tool on macOS and fails with `tmux` by default
|
||||||
@ -44,7 +51,6 @@ class Caveats
|
|||||||
if ENV["TMUX"] && !quiet_system("/usr/bin/pbpaste")
|
if ENV["TMUX"] && !quiet_system("/usr/bin/pbpaste")
|
||||||
s << "" << "WARNING: brew services will fail when run under tmux."
|
s << "" << "WARNING: brew services will fail when run under tmux."
|
||||||
end
|
end
|
||||||
end
|
|
||||||
"#{s.join("\n")}\n" unless s.empty?
|
"#{s.join("\n")}\n" unless s.empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -114,6 +114,20 @@ describe Caveats do
|
|||||||
expect(caveats).to include(f.plist_manual)
|
expect(caveats).to include(f.plist_manual)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "gives information about service" do
|
||||||
|
f = formula do
|
||||||
|
url "foo-1.0"
|
||||||
|
service do
|
||||||
|
run [bin/"php", "test"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
caveats = described_class.new(f).caveats
|
||||||
|
|
||||||
|
expect(f.service?).to eq(true)
|
||||||
|
expect(caveats).to include("#{f.bin}/php test")
|
||||||
|
expect(caveats).to include("background service")
|
||||||
|
end
|
||||||
|
|
||||||
it "warns about brew failing under tmux" do
|
it "warns about brew failing under tmux" do
|
||||||
f = formula do
|
f = formula do
|
||||||
url "foo-1.0"
|
url "foo-1.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user