Port Homebrew::Cmd::Postinstall
This commit is contained in:
parent
31aa89aa7c
commit
427b527335
@ -1,35 +1,33 @@
|
||||
# typed: true
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "abstract_command"
|
||||
require "sandbox"
|
||||
require "formula_installer"
|
||||
require "cli/parser"
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
module Cmd
|
||||
class Postinstall < AbstractCommand
|
||||
cmd_args do
|
||||
description <<~EOS
|
||||
Rerun the post-install steps for <formula>.
|
||||
EOS
|
||||
|
||||
sig { returns(CLI::Parser) }
|
||||
def postinstall_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
description <<~EOS
|
||||
Rerun the post-install steps for <formula>.
|
||||
EOS
|
||||
named_args :installed_formula, min: 1
|
||||
end
|
||||
|
||||
named_args :installed_formula, min: 1
|
||||
end
|
||||
end
|
||||
|
||||
def postinstall
|
||||
args = postinstall_args.parse
|
||||
|
||||
args.named.to_resolved_formulae.each do |f|
|
||||
ohai "Postinstalling #{f}"
|
||||
f.install_etc_var
|
||||
if f.post_install_defined?
|
||||
fi = FormulaInstaller.new(f, **{ debug: args.debug?, quiet: args.quiet?, verbose: args.verbose? }.compact)
|
||||
fi.post_install
|
||||
else
|
||||
opoo "#{f}: no `post_install` method was defined in the formula!"
|
||||
sig { override.void }
|
||||
def run
|
||||
args.named.to_resolved_formulae.each do |f|
|
||||
ohai "Postinstalling #{f}"
|
||||
f.install_etc_var
|
||||
if f.post_install_defined?
|
||||
fi = FormulaInstaller.new(f, **{ debug: args.debug?, quiet: args.quiet?, verbose: args.verbose? }.compact)
|
||||
fi.post_install
|
||||
else
|
||||
opoo "#{f}: no `post_install` method was defined in the formula!"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -12,13 +12,13 @@ require "cli/parser"
|
||||
require "cmd/postinstall"
|
||||
|
||||
begin
|
||||
args = Homebrew.postinstall_args.parse
|
||||
args = Homebrew::Cmd::Postinstall.new.args
|
||||
error_pipe = UNIXSocket.open(ENV.fetch("HOMEBREW_ERROR_PIPE"), &:recv_io)
|
||||
error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
||||
|
||||
trap("INT", old_trap)
|
||||
|
||||
formula = args.named.to_resolved_formulae.first
|
||||
formula = T.must(args.named.to_resolved_formulae.first)
|
||||
if args.debug?
|
||||
require "debrew"
|
||||
formula.extend(Debrew::Formula)
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/postinstall"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
RSpec.describe "brew postinstall" do
|
||||
RSpec.describe Homebrew::Cmd::Postinstall do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user