Merge pull request #20345 from Homebrew/assertions-typecheck

formula_assertions: fix typechecking error in `{shell,pipe}_output`
This commit is contained in:
Carlo Cabrera 2025-08-01 10:09:39 +00:00 committed by GitHub
commit f5bddacf0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,7 +26,8 @@ module Homebrew
# @api public
sig { params(cmd: T.any(Pathname, String), result: Integer).returns(String) }
def shell_output(cmd, result = 0)
ohai cmd
ohai cmd.to_s
assert_path_exists cmd, "Pathname '#{cmd}' does not exist!" if cmd.is_a?(Pathname)
output = `#{cmd}`
assert_equal result, $CHILD_STATUS.exitstatus
output
@ -41,7 +42,8 @@ module Homebrew
# @api public
sig { params(cmd: T.any(String, Pathname), input: T.nilable(String), result: T.nilable(Integer)).returns(String) }
def pipe_output(cmd, input = nil, result = nil)
ohai cmd
ohai cmd.to_s
assert_path_exists cmd, "Pathname '#{cmd}' does not exist!" if cmd.is_a?(Pathname)
output = IO.popen(cmd, "w+") do |pipe|
pipe.write(input) unless input.nil?
pipe.close_write