From 4c016c9b27a4346e61ed1cd2b2978a1b0d417c7c Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 7 Feb 2025 13:31:16 +0000 Subject: [PATCH] {brew,cask}_installer: fix non-verbose postinstall. This wasn't working as expected for multiple argument `postinstall`s unless in verbose mode so let's just use `Kernel.system` directly (which verbose mode was doing anyway and we already use in a few places) --- lib/bundle/brew_installer.rb | 4 ++-- lib/bundle/cask_installer.rb | 4 ++-- spec/bundle/brew_installer_spec.rb | 6 +++--- spec/bundle/cask_installer_spec.rb | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/bundle/brew_installer.rb b/lib/bundle/brew_installer.rb index 00c841d465..9c85adccf6 100644 --- a/lib/bundle/brew_installer.rb +++ b/lib/bundle/brew_installer.rb @@ -140,8 +140,8 @@ def postinstall_change_state!(verbose:) return true if @postinstall.blank? return true unless changed? - puts "Running postinstall for #{@name}." if verbose - Bundle.system(@postinstall, verbose:) + puts "Running postinstall for #{@name}: #{@postinstall}" if verbose + Kernel.system(@postinstall) end def self.formula_installed_and_up_to_date?(formula, no_upgrade: false) diff --git a/lib/bundle/cask_installer.rb b/lib/bundle/cask_installer.rb index ec4c9c804f..4c193e3490 100644 --- a/lib/bundle/cask_installer.rb +++ b/lib/bundle/cask_installer.rb @@ -75,8 +75,8 @@ def postinstall_change_state!(name:, options:, verbose:) postinstall = options.fetch(:postinstall, nil) return true if postinstall.blank? - puts "Running postinstall for #{name}." if verbose - Bundle.system(postinstall, verbose:) + puts "Running postinstall for #{@name}: #{postinstall}" if verbose + Kernel.system(postinstall) end def self.cask_installed_and_up_to_date?(cask, no_upgrade: false) diff --git a/spec/bundle/brew_installer_spec.rb b/spec/bundle/brew_installer_spec.rb index 944b73f1fc..a11137967b 100644 --- a/spec/bundle/brew_installer_spec.rb +++ b/spec/bundle/brew_installer_spec.rb @@ -217,13 +217,13 @@ end it "runs the postinstall command" do - expect(Bundle).to receive(:system).with("custom command", verbose: false).and_return(true) + expect(Kernel).to receive(:system).with("custom command").and_return(true) described_class.preinstall(formula, postinstall: "custom command") described_class.install(formula, postinstall: "custom command") end it "reports a failure" do - expect(Bundle).to receive(:system).with("custom command", verbose: false).and_return(false) + expect(Kernel).to receive(:system).with("custom command").and_return(false) described_class.preinstall(formula, postinstall: "custom command") expect(described_class.install(formula, postinstall: "custom command")).to be(false) end @@ -235,7 +235,7 @@ end it "does not run the postinstall command" do - expect(Bundle).not_to receive(:system) + expect(Kernel).not_to receive(:system) described_class.preinstall(formula, postinstall: "custom command") described_class.install(formula, postinstall: "custom command") end diff --git a/spec/bundle/cask_installer_spec.rb b/spec/bundle/cask_installer_spec.rb index 5036960e33..b69f466f2a 100644 --- a/spec/bundle/cask_installer_spec.rb +++ b/spec/bundle/cask_installer_spec.rb @@ -145,13 +145,13 @@ end it "runs the postinstall command" do - expect(Bundle).to receive(:system).with("custom command", verbose: false).and_return(true) + expect(Kernel).to receive(:system).with("custom command").and_return(true) expect(described_class.preinstall("google-chrome", postinstall: "custom command")).to be(true) expect(described_class.install("google-chrome", postinstall: "custom command")).to be(true) end it "reports a failure when postinstall fails" do - expect(Bundle).to receive(:system).with("custom command", verbose: false).and_return(false) + expect(Kernel).to receive(:system).with("custom command").and_return(false) expect(described_class.preinstall("google-chrome", postinstall: "custom command")).to be(true) expect(described_class.install("google-chrome", postinstall: "custom command")).to be(false) end