Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix brew bundle --cleanup from stdin #1379

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def run
file: args.file,
force: true,
zap: args.zap?,
dsl: Bundle::Commands::Install.dsl,
)
end
when "dump"
Expand Down
4 changes: 3 additions & 1 deletion lib/bundle/commands/cleanup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def reset!
Bundle::BrewServices.reset!
end

def run(global: false, file: nil, force: false, zap: false)
def run(global: false, file: nil, force: false, zap: false, dsl: nil)
@dsl ||= dsl

casks = casks_to_uninstall(global:, file:)
formulae = formulae_to_uninstall(global:, file:)
taps = taps_to_untap(global:, file:)
Expand Down
4 changes: 2 additions & 2 deletions lib/bundle/commands/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ def run(*args, global: false, file: nil)
command_path = command_path.dirname.to_s
end

brewfile = Brewfile.read(global:, file:)
@dsl = Brewfile.read(global:, file:)

require "formula"
require "formulary"

ENV.deps = brewfile.entries.map do |entry|
ENV.deps = @dsl.entries.map do |entry|
next if entry.type != :brew

f = Formulary.factory(entry.name)
Expand Down
8 changes: 6 additions & 2 deletions lib/bundle/commands/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ module Install
module_function

def run(global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false, quiet: false)
parsed_entries = Brewfile.read(global:, file:).entries
@dsl = Brewfile.read(global:, file:)
Bundle::Installer.install(
parsed_entries,
@dsl.entries,
global:, file:, no_lock:, no_upgrade:, verbose:, force:, quiet:,
) || exit(1)
end

def dsl
@dsl
end
end
end
end
12 changes: 12 additions & 0 deletions spec/bundle/commands/install_command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
expect { described_class.run }.not_to raise_error
end

it "#dsl returns a valid DSL" do
allow(Bundle::TapInstaller).to receive(:preinstall).and_return(false)
allow(Bundle::WhalebrewInstaller).to receive(:preinstall).and_return(false)
allow(Bundle::VscodeExtensionInstaller).to receive(:preinstall).and_return(false)
allow(Bundle::BrewInstaller).to receive_messages(preinstall: true, install: true)
allow(Bundle::CaskInstaller).to receive_messages(preinstall: true, install: true)
allow(Bundle::MacAppStoreInstaller).to receive_messages(preinstall: true, install: true)
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)
described_class.run
expect(described_class.dsl.entries.first.name).to eql("phinze/cask")
end

it "does not raise an error when skippable" do
expect(Bundle::BrewInstaller).not_to receive(:install)

Expand Down
Loading