Mike McQuaid 70b93f65ea
*cmd/*: use *system instead of exec for easier testing.
This improves both test coverage, makes it easier to use a profiler and
a debugger.
2019-03-27 21:15:24 +00:00

25 lines
519 B
Ruby

require "cli_parser"
module Homebrew
module_function
def prof_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`prof` <command>
Run Homebrew with the Ruby profiler e.g. `brew prof readall`.
EOS
end
end
def prof
prof_args.parse
Homebrew.install_gem_setup_path! "ruby-prof"
FileUtils.mkdir_p "prof"
brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
safe_system "ruby-prof", "--printer=multi", "--file=prof", brew_rb, "--", *ARGV
end
end