fohte / rubocop-daemon

Makes RuboCop faster
MIT License
222 stars 26 forks source link

Fallback to standard Rubocop binary #16

Closed dbalatero closed 5 years ago

dbalatero commented 5 years ago

Not all projects or gemsets will have rubocop-daemon installed. This will make rubocop-daemon-wrapper more of a drop-in replacement in those scenarios by falling back to rubocop when rubocop-daemon is not available.

This way, setting the global rubocop executable inside Vim/VSCode/etc will not fail when opening Ruby files outside of projects that use this daemon gem.

dbalatero commented 5 years ago

I agree - I am out of the country for two weeks but I can change it when I'm back or please feel free to make the change and merge it now!

David

On Sun, Oct 6, 2019 at 4:57 PM Hayato Kawai notifications@github.com wrote:

@fohte commented on this pull request.

Thanks for your contribution! I left a comment for a small issue.

In bin/rubocop-daemon-wrapper https://github.com/fohte/rubocop-daemon/pull/16#discussion_r331777889:

set -e

+COMMAND_PREFIX=""

+

+if [ -n "$RUBOCOP_DAEMON_USE_BUNDLER" ]; then

  • COMMAND_PREFIX="bundle exec"

+fi

+

+if ! command -v rubocop-daemon; then

⬇️ Suggested change

-if ! command -v rubocop-daemon; then

+if ! command -v rubocop-daemon > /dev/null; then

command -v prints the path of rubocop-daemon when rubocop-daemon is available, so we should redirect to /dev/null to get rid of this output.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fohte/rubocop-daemon/pull/16?email_source=notifications&email_token=AAAOQJMMVG2RCZNGNKLKJCLQNGR6XA5CNFSM4I5HLIU2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCHAHS2Q#pullrequestreview-297826666, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAOQJKRR7NF27FIQYLCL5TQNGR6XANCNFSM4I5HLIUQ .

cbliard commented 5 years ago

It looks like if rubocop is aliased to rubocop-daemon-wrapper as suggested in the README, and bundler is not used, then rubocop will call itself indefinitely. Is that correct?