Skip to content

Commit

Permalink
Merge 8bfa3a7 into a044046
Browse files Browse the repository at this point in the history
  • Loading branch information
desheikh committed Aug 26, 2021
2 parents a044046 + 8bfa3a7 commit fa44ac5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/guard/rubocop/runner.rb
Expand Up @@ -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.
Expand Down
16 changes: 16 additions & 0 deletions spec/guard/rubocop/runner_spec.rb
Expand Up @@ -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] }
Expand Down

0 comments on commit fa44ac5

Please sign in to comment.