File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 5757desc ( "Format `*.rb`" )
5858multitask ( :"format:rb" ) do
5959 # while `syntax_tree` is much faster than `rubocop`, `rubocop` is the only formatter with full syntax support
60- files = ENV . key? ( FILES_ENV ) ? %w[ sed -E -n -e /\.rb$/p -- ] << ENV . fetch ( FILES_ENV ) : %w[ find ./lib ./test ./examples -type f -and -name *.rb -print0 ]
60+ files = ENV . key? ( FILES_ENV ) ? %w[ sed -E -z - n -e /\.rb$/p -- ] << ENV . fetch ( FILES_ENV ) : %w[ find ./lib ./test ./examples -type f -and -name *.rb -print0 ]
6161 fmt = xargs + %w[ rubocop --fail-level F --autocorrect --format simple -- ]
6262 sh ( "#{ files . shelljoin } | #{ fmt . shelljoin } " )
6363end
6464
6565desc ( "Format `*.rbi`" )
6666multitask ( :"format:rbi" ) do
67- files = ENV . key? ( FILES_ENV ) ? %w[ sed -E -n -e /\.rbi$/p -- ] << ENV . fetch ( FILES_ENV ) : %w[ find ./rbi -type f -and -name *.rbi -print0 ]
67+ files = ENV . key? ( FILES_ENV ) ? %w[ sed -E -z - n -e /\.rbi$/p -- ] << ENV . fetch ( FILES_ENV ) : %w[ find ./rbi -type f -and -name *.rbi -print0 ]
6868 fmt = xargs + %w[ stree write -- ]
6969 sh ( ruby_opt , "#{ files . shelljoin } | #{ fmt . shelljoin } " )
7070end
7171
7272desc ( "Format `*.rbs`" )
7373multitask ( :"format:rbs" ) do
74- files = ENV . key? ( FILES_ENV ) ? %w[ sed -E -n -e /\.rbs$/p -- ] << ENV . fetch ( FILES_ENV ) : %w[ find ./sig -type f -name *.rbs -print0 ]
74+ files = ENV . key? ( FILES_ENV ) ? %w[ sed -E -z - n -e /\.rbs$/p -- ] << ENV . fetch ( FILES_ENV ) : %w[ find ./sig -type f -name *.rbs -print0 ]
7575 inplace = /darwin|bsd/ =~ RUBY_PLATFORM ? [ "-i" , "" ] : %w[ -i ]
7676 uuid = SecureRandom . uuid
7777
Original file line number Diff line number Diff line change @@ -6,13 +6,16 @@ echo "Script started with $# arguments"
66echo " Arguments: $* "
77echo " Script location: $( dirname " $0 " ) "
88
9- cd " $( dirname " $0 " ) /.."
10- echo " Changed to directory: $( pwd ) "
9+ cd -- " $( dirname " $0 " ) /.."
10+ echo " Changed to directory: $PWD "
1111
1212if [ $# -eq 0 ]; then
1313 echo " Usage: $0 <file-with-paths> [additional-formatter-args...]"
1414 echo " The file should contain one file path per line"
1515 exit 1
1616fi
1717
18- FORMAT_FILE=" $1 " exec -- bundle exec rake format
18+ FILE=" $( mktemp) "
19+ tr -- ' \n' ' \0' < " $1 " > " $FILE "
20+
21+ exec -- bundle exec rake format FORMAT_FILE=" $FILE "
You can’t perform that action at this time.
0 commit comments