Merge pull request #1947 from reitermarkus/rubocop-constants
Use constants for RuboCop version.
This commit is contained in:
commit
cfc90af3cb
@ -23,12 +23,10 @@ module Hbc
|
|||||||
$CHILD_STATUS.success?
|
$CHILD_STATUS.success?
|
||||||
end
|
end
|
||||||
|
|
||||||
RUBOCOP_CASK_VERSION = "~> 0.10.6".freeze
|
|
||||||
|
|
||||||
def install_rubocop
|
def install_rubocop
|
||||||
Utils.capture_stderr do
|
Utils.capture_stderr do
|
||||||
begin
|
begin
|
||||||
Homebrew.install_gem_setup_path! "rubocop-cask", RUBOCOP_CASK_VERSION, "rubocop"
|
Homebrew.install_gem_setup_path! "rubocop-cask", HOMEBREW_RUBOCOP_CASK_VERSION, "rubocop"
|
||||||
rescue SystemExit
|
rescue SystemExit
|
||||||
raise CaskError, Tty.strip_ansi($stderr.string).chomp.sub(/\AError: /, "")
|
raise CaskError, Tty.strip_ansi($stderr.string).chomp.sub(/\AError: /, "")
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
require "English"
|
require "English"
|
||||||
|
require "open3"
|
||||||
|
require "rubygems"
|
||||||
|
|
||||||
describe Hbc::CLI::Style do
|
describe Hbc::CLI::Style do
|
||||||
let(:args) { [] }
|
let(:args) { [] }
|
||||||
@ -77,6 +79,20 @@ describe Hbc::CLI::Style do
|
|||||||
expect { subject }.to raise_error(Hbc::CaskError)
|
expect { subject }.to raise_error(Hbc::CaskError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "version" do
|
||||||
|
it "matches `HOMEBREW_RUBOCOP_VERSION`" do
|
||||||
|
stdout, status = Open3.capture2("gem", "dependency", "rubocop-cask", "--version", HOMEBREW_RUBOCOP_CASK_VERSION, "--pipe", "--remote")
|
||||||
|
|
||||||
|
expect(status).to be_a_success
|
||||||
|
|
||||||
|
requirement = Gem::Requirement.new(stdout.scan(/rubocop --version '(.*)'/).flatten.first)
|
||||||
|
version = Gem::Version.new(HOMEBREW_RUBOCOP_VERSION)
|
||||||
|
|
||||||
|
expect(requirement).not_to be_none
|
||||||
|
expect(requirement).to be_satisfied_by(version)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#cask_paths" do
|
describe "#cask_paths" do
|
||||||
|
|||||||
@ -47,7 +47,7 @@ module Homebrew
|
|||||||
|
|
||||||
def check_style_impl(files, output_type, options = {})
|
def check_style_impl(files, output_type, options = {})
|
||||||
fix = options[:fix]
|
fix = options[:fix]
|
||||||
Homebrew.install_gem_setup_path! "rubocop", "0.47.1"
|
Homebrew.install_gem_setup_path! "rubocop", HOMEBREW_RUBOCOP_VERSION
|
||||||
|
|
||||||
args = %w[
|
args = %w[
|
||||||
--force-exclusion
|
--force-exclusion
|
||||||
|
|||||||
@ -2,6 +2,8 @@ unless ENV["HOMEBREW_BREW_FILE"]
|
|||||||
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!"
|
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require "constants"
|
||||||
|
|
||||||
# Path to `bin/brew` main executable in HOMEBREW_PREFIX
|
# Path to `bin/brew` main executable in HOMEBREW_PREFIX
|
||||||
HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"])
|
HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"])
|
||||||
|
|
||||||
|
|||||||
3
Library/Homebrew/constants.rb
Normal file
3
Library/Homebrew/constants.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# RuboCop version used for `brew style` and `brew cask style`
|
||||||
|
HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze
|
||||||
|
HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.11.0".freeze # has to be updated when RuboCop version changes
|
||||||
@ -2,6 +2,8 @@ unless ENV["HOMEBREW_BREW_FILE"]
|
|||||||
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!"
|
raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require "constants"
|
||||||
|
|
||||||
require "tmpdir"
|
require "tmpdir"
|
||||||
require "pathname"
|
require "pathname"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user