service: ensure environment variables are strings

This commit is contained in:
Sean Molenaar 2021-05-22 10:43:39 +02:00 committed by Sean Molenaar
parent 6f1398a533
commit 3ce5737425
No known key found for this signature in database
GPG Key ID: 6BF5D8DF0D34FAAE
2 changed files with 5 additions and 5 deletions

View File

@ -135,13 +135,11 @@ module Homebrew
end
end
sig { params(variables: T.nilable(T::Hash[String, String])).returns(T.nilable(T::Hash[String, String])) }
sig { params(variables: T::Hash[String, String]).returns(T.nilable(T::Hash[String, String])) }
def environment_variables(variables = {})
case T.unsafe(variables)
when nil
@environment_variables
when Hash
@environment_variables = variables
@environment_variables = variables.transform_values(&:to_s)
else
raise TypeError, "Service#environment_variables expects a hash"
end

View File

@ -69,7 +69,7 @@ describe Homebrew::Service do
f.class.service do
run [opt_bin/"beanstalkd", "test"]
run_type :immediate
environment_variables PATH: std_service_path_env, FOO: "BAR"
environment_variables PATH: std_service_path_env, FOO: "BAR", ETC_DIR: etc/"beanstalkd"
error_log_path var/"log/beanstalkd.error.log"
log_path var/"log/beanstalkd.log"
input_path var/"in/beanstalkd"
@ -88,6 +88,8 @@ describe Homebrew::Service do
<dict>
\t<key>EnvironmentVariables</key>
\t<dict>
\t\t<key>ETC_DIR</key>
\t\t<string>#{HOMEBREW_PREFIX}/etc/beanstalkd</string>
\t\t<key>FOO</key>
\t\t<string>BAR</string>
\t\t<key>PATH</key>