mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 14:29:31 +00:00
49 lines
1.2 KiB
Bash
Executable File
49 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Usage:
|
|
# bin/rubocop [-A|-t|-h]
|
|
# bin/rubocop [file or path] [cli options]
|
|
#
|
|
# Options:
|
|
# -A Autocorrect
|
|
# -t AutoGenConfig
|
|
# --update-config Update config from Rails
|
|
# -h,--help,help Usage
|
|
|
|
set -eou pipefail
|
|
|
|
case $1 in
|
|
-A)
|
|
echo "Rubocop autocorrect is ON" >&2
|
|
bin/rake -f lib/tasks/rubocop.rake rubocop:auto_correct
|
|
;;
|
|
|
|
-t)
|
|
echo "Rubocop is generating a new TODO" >&2
|
|
bin/rake -f lib/tasks/rubocop.rake rubocop:auto_gen_config
|
|
;;
|
|
|
|
-h|--help|help)
|
|
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
|
|
;;
|
|
|
|
--update-config)
|
|
curl -X GET https://raw.githubusercontent.com/rails/rails/master/.rubocop.yml -o .rubocop.yml
|
|
bundle check || bundle install --local || bundle install
|
|
echo "Current rubocop version is:"
|
|
bundle show rubocop
|
|
echo "Rails rubocop version is:"
|
|
curl -X GET https://raw.githubusercontent.com/rails/rails/master/Gemfile | grep rubocop
|
|
;;
|
|
|
|
*)
|
|
# with no args, run vanilla rubocop
|
|
# else assume we're passing in arbitrary arguments
|
|
if [ -z "$1" ]; then
|
|
bin/rake -f lib/tasks/rubocop.rake rubocop
|
|
else
|
|
bundle exec rubocop "$@"
|
|
fi
|
|
;;
|
|
esac
|