From 52612fb468bd1a909609812d6df9ff96f61cb937 Mon Sep 17 00:00:00 2001 From: Zulfiqar Ali Date: Tue, 12 Apr 2016 20:47:24 -0400 Subject: [PATCH 1/2] allow custom cmd option for rubocop --- lib/guard/rubocop/runner.rb | 2 +- spec/guard/rubocop/runner_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/guard/rubocop/runner.rb b/lib/guard/rubocop/runner.rb index 7509f6c..c40a31b 100644 --- a/lib/guard/rubocop/runner.rb +++ b/lib/guard/rubocop/runner.rb @@ -28,7 +28,7 @@ def run(paths = []) end def build_command(paths) - command = ['rubocop'] + command = [@options[:cmd] || 'rubocop'] if should_add_default_formatter_for_console? command.concat(%w[--format progress]) # Keep default formatter for console. diff --git a/spec/guard/rubocop/runner_spec.rb b/spec/guard/rubocop/runner_spec.rb index 2a913db..5587996 100644 --- a/spec/guard/rubocop/runner_spec.rb +++ b/spec/guard/rubocop/runner_spec.rb @@ -109,6 +109,22 @@ let(:options) { { cli: %w[--debug --rails] } } let(:paths) { %w[file1.rb file2.rb] } + describe ':cmd option' do + context 'when set' do + let(:options) { { cmd: 'bin/rubocop' } } + + it 'uses the supplied :cmd' do + expect(build_command[0]).to eq('bin/rubocop') + end + end + + context 'when not set' do + it 'uses the default command' do + expect(build_command[0]).to eq('rubocop') + end + end + end + context 'when :hide_stdout is not set' do context 'and :cli option includes formatter for console' do before { options[:cli] = %w[--format simple] } From 8bfa3a75dcb7541491e7ce6738b0ca67aaaa1de1 Mon Sep 17 00:00:00 2001 From: Zulfiqar Ali Date: Thu, 26 Aug 2021 09:22:09 -0400 Subject: [PATCH 2/2] update README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 4a69fb6..2b54975 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,9 @@ all_on_start: true # Check all files at Guard startup. cli: '--rails' # Pass arbitrary RuboCop CLI arguments. # An array or string is acceptable. # default: nil +cmd: './bin/rubocop' # Pass custom cmd to run rubocop. + # default: rubocop + hide_stdout: false # Do not display console output (in case outputting to file). # default: false keep_failed: true # Keep failed files until they pass.