formulary: sub home placeholder in caveats
We set a placeholder for the home directory when generating API JSON so we should substitute the actual home directory back in when printing caveats locally. This allows people to use `Dir.home` in caveats and have it display correctly no matter the platform or operating system.
This commit is contained in:
parent
664ac04782
commit
d57f291a1e
@ -287,6 +287,7 @@ module Formulary
|
|||||||
def caveats
|
def caveats
|
||||||
self.class.instance_variable_get(:@caveats_string)
|
self.class.instance_variable_get(:@caveats_string)
|
||||||
&.gsub(HOMEBREW_PREFIX_PLACEHOLDER, HOMEBREW_PREFIX)
|
&.gsub(HOMEBREW_PREFIX_PLACEHOLDER, HOMEBREW_PREFIX)
|
||||||
|
&.gsub(HOMEBREW_HOME_PLACEHOLDER, Dir.home)
|
||||||
end
|
end
|
||||||
|
|
||||||
@tap_git_head_string = json_formula["tap_git_head"]
|
@tap_git_head_string = json_formula["tap_git_head"]
|
||||||
|
|||||||
@ -270,7 +270,7 @@ describe Formulary do
|
|||||||
"conflicts_with" => ["conflicting_formula"],
|
"conflicts_with" => ["conflicting_formula"],
|
||||||
"conflicts_with_reasons" => ["it does"],
|
"conflicts_with_reasons" => ["it does"],
|
||||||
"link_overwrite" => ["bin/abc"],
|
"link_overwrite" => ["bin/abc"],
|
||||||
"caveats" => "example caveat string",
|
"caveats" => "example caveat string\n/$HOME\n$HOMEBREW_PREFIX",
|
||||||
"service" => {
|
"service" => {
|
||||||
"run" => ["$HOMEBREW_PREFIX/opt/formula_name/bin/beanstalkd", "test"],
|
"run" => ["$HOMEBREW_PREFIX/opt/formula_name/bin/beanstalkd", "test"],
|
||||||
"run_type" => "immediate",
|
"run_type" => "immediate",
|
||||||
@ -356,7 +356,7 @@ describe Formulary do
|
|||||||
expect(formula.conflicts.map(&:reason)).to include "it does"
|
expect(formula.conflicts.map(&:reason)).to include "it does"
|
||||||
expect(formula.class.link_overwrite_paths).to include "bin/abc"
|
expect(formula.class.link_overwrite_paths).to include "bin/abc"
|
||||||
|
|
||||||
expect(formula.caveats).to eq "example caveat string"
|
expect(formula.caveats).to eq "example caveat string\n#{Dir.home}\n#{HOMEBREW_PREFIX}"
|
||||||
|
|
||||||
expect(formula).to be_a_service
|
expect(formula).to be_a_service
|
||||||
expect(formula.service.command).to eq(["#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd", "test"])
|
expect(formula.service.command).to eq(["#{HOMEBREW_PREFIX}/opt/formula_name/bin/beanstalkd", "test"])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user