2021-01-06 15:21:09 +00:00
|
|
|
#: * `rubocop`
|
|
|
|
#:
|
|
|
|
#: Installs, configures and runs Homebrew's `rubocop`.
|
|
|
|
|
2021-04-20 23:30:20 +09:00
|
|
|
# HOMEBREW_LIBRARY is from the user environment.
|
|
|
|
# HOMEBREW_RUBY_PATH is set by utils/ruby.sh
|
|
|
|
# RUBY_DISABLE_OPTIONS is set by brew.sh
|
|
|
|
# HOMEBREW_BREW_FILE is set by extend/ENV/super.rb
|
|
|
|
# shellcheck disable=SC2154
|
2021-01-06 15:21:09 +00:00
|
|
|
homebrew-rubocop() {
|
2021-04-20 23:30:20 +09:00
|
|
|
source "${HOMEBREW_LIBRARY}/Homebrew/utils/ruby.sh"
|
2021-01-06 15:21:09 +00:00
|
|
|
setup-ruby-path
|
|
|
|
|
2021-04-20 23:30:20 +09:00
|
|
|
GEM_VERSION="$("${HOMEBREW_RUBY_PATH}" "${RUBY_DISABLE_OPTIONS}" -rrbconfig -e 'puts RbConfig::CONFIG["ruby_version"]')"
|
|
|
|
GEM_HOME="${HOMEBREW_LIBRARY}/Homebrew/vendor/bundle/ruby/${GEM_VERSION}"
|
2021-01-06 15:21:09 +00:00
|
|
|
|
2021-04-20 23:30:20 +09:00
|
|
|
if ! [[ -f "${GEM_HOME}/bin/rubocop" ]]; then
|
|
|
|
"${HOMEBREW_BREW_FILE}" install-bundler-gems
|
2021-01-06 15:21:09 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
export GEM_HOME
|
2021-04-20 23:30:20 +09:00
|
|
|
export PATH="${GEM_HOME}/bin:${PATH}"
|
2021-01-06 15:21:09 +00:00
|
|
|
|
2021-04-20 23:30:20 +09:00
|
|
|
RUBOCOP="${HOMEBREW_LIBRARY}/Homebrew/utils/rubocop.rb"
|
|
|
|
exec "${HOMEBREW_RUBY_PATH}" "${RUBOCOP}" "$@"
|
2021-01-06 15:21:09 +00:00
|
|
|
}
|