From 54c4580871f1e029f2d18343bb65b27450d807cd Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 29 May 2017 01:21:36 +0200 Subject: Use `XDG_CACHE_HOME` for RuboCop. --- Library/Homebrew/cask/lib/hbc/cli/style.rb | 2 +- Library/Homebrew/cmd/style.rb | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/lib/hbc/cli/style.rb b/Library/Homebrew/cask/lib/hbc/cli/style.rb index 078796e7e..03159a0cf 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/style.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/style.rb @@ -11,7 +11,7 @@ module Hbc def run install_rubocop - system "rubocop", *rubocop_args, "--", *cask_paths + system({ "XDG_CACHE_HOME" => HOMEBREW_CACHE }, "rubocop", *rubocop_args, "--", *cask_paths) raise CaskError, "style check failed" unless $CHILD_STATUS.success? true end diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index 687ee36b8..228aa360e 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -19,6 +19,7 @@ require "utils" require "json" +require "open3" module Homebrew module_function @@ -104,16 +105,16 @@ module Homebrew when :print args << "--display-cop-names" if ARGV.include? "--display-cop-names" args << "--format" << "simple" if files - system "rubocop", *args + system({ "XDG_CACHE_HOME" => HOMEBREW_CACHE }, "rubocop", *args) !$?.success? when :json - json = Utils.popen_read_text("rubocop", "--format", "json", *args) + json, _, status = Open3.capture3({ "XDG_CACHE_HOME" => HOMEBREW_CACHE }, "rubocop", "--format", "json", *args) # exit status of 1 just means violations were found; other numbers mean # execution errors. # exitstatus can also be nil if RuboCop process crashes, e.g. due to # native extension problems. # JSON needs to be at least 2 characters. - if $?.exitstatus.nil? || $?.exitstatus > 1 || json.to_s.length < 2 + if !status.success? || json.to_s.length < 2 raise "Error running `rubocop --format json #{args.join " "}`" end RubocopResults.new(JSON.parse(json)) -- cgit v1.2.3 From dc4f30393741ab7bc8115fa68d8bbbee404f22d9 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 29 May 2017 01:45:05 +0200 Subject: Remove unused `popen_read_text` method. --- Library/Homebrew/utils/popen.rb | 4 ---- 1 file changed, 4 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/utils/popen.rb b/Library/Homebrew/utils/popen.rb index 350d9a09f..4e03711a1 100644 --- a/Library/Homebrew/utils/popen.rb +++ b/Library/Homebrew/utils/popen.rb @@ -3,10 +3,6 @@ module Utils popen(args, "rb", &block) end - def self.popen_read_text(*args, &block) - popen(args, "r", &block) - end - def self.popen_write(*args, &block) popen(args, "wb", &block) end -- cgit v1.2.3