Skip to content

Commit

Permalink
Merge pull request #1595 from Homebrew/fix_postinstall
Browse files Browse the repository at this point in the history
{brew,cask}_installer: fix non-verbose postinstall.
  • Loading branch information
MikeMcQuaid authored Feb 7, 2025
2 parents ac88e94 + 4c016c9 commit a72114b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/bundle/brew_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/bundle/cask_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions spec/bundle/brew_installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/bundle/cask_installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a72114b

Please sign in to comment.