mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Port Homebrew::Cmd::Cleanup
This commit is contained in:
parent
a8f8c65d93
commit
adf47bb11b
@ -1,15 +1,13 @@
|
|||||||
# typed: strict
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "cleanup"
|
require "cleanup"
|
||||||
require "cli/parser"
|
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module Cmd
|
||||||
|
class CleanupCmd < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def cleanup_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
days = Homebrew::EnvConfig::ENVS[:HOMEBREW_CLEANUP_MAX_AGE_DAYS][:default]
|
days = Homebrew::EnvConfig::ENVS[:HOMEBREW_CLEANUP_MAX_AGE_DAYS][:default]
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Remove stale lock files and outdated downloads for all formulae and casks,
|
Remove stale lock files and outdated downloads for all formulae and casks,
|
||||||
@ -31,12 +29,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args [:formula, :cask]
|
named_args [:formula, :cask]
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
sig { void }
|
|
||||||
def cleanup
|
|
||||||
args = cleanup_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
days = args.prune.presence&.then do |prune|
|
days = args.prune.presence&.then do |prune|
|
||||||
case prune
|
case prune
|
||||||
when /\A\d+\Z/
|
when /\A\d+\Z/
|
||||||
@ -73,3 +68,5 @@ module Homebrew
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cmd/cleanup"
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
|
||||||
RSpec.describe "brew cleanup" do
|
RSpec.describe Homebrew::Cmd::CleanupCmd do
|
||||||
before do
|
before do
|
||||||
FileUtils.mkdir_p HOMEBREW_LIBRARY/"Homebrew/vendor/"
|
FileUtils.mkdir_p HOMEBREW_LIBRARY/"Homebrew/vendor/"
|
||||||
FileUtils.touch HOMEBREW_LIBRARY/"Homebrew/vendor/portable-ruby-version"
|
FileUtils.touch HOMEBREW_LIBRARY/"Homebrew/vendor/portable-ruby-version"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user