brew/Library/Homebrew/cmd/update-if-needed.rb
Mike McQuaid 5ec5063dc7
Add brew update-if-needed
This uses the logic in `brew.sh` for deciding whether or not to run
`brew update --auto-update` and makes it a dedicated command that can
be used instead of `brew update` in scripts to be really fast in the
no-op case.

`brew update` will always do at least some updating which is a nicer
default but is much slower.
2025-03-27 13:16:00 +00:00

24 lines
512 B
Ruby

# typed: strict
# frozen_string_literal: true
require "abstract_command"
require "shell_command"
module Homebrew
module Cmd
class UpdateIfNeeded < AbstractCommand
include ShellCommand
cmd_args do
description <<~EOS
Runs `brew update --auto-update` only if needed.
This is a good replacement for `brew update` in scripts where you want
the no-op case to be both possible and really fast.
EOS
named_args :none
end
end
end
end