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 57
57
desc ( "Format `*.rb`" )
58
58
multitask ( :"format:rb" ) do
59
59
# 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 ]
61
61
fmt = xargs + %w[ rubocop --fail-level F --autocorrect --format simple -- ]
62
62
sh ( "#{ files . shelljoin } | #{ fmt . shelljoin } " )
63
63
end
64
64
65
65
desc ( "Format `*.rbi`" )
66
66
multitask ( :"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 ]
68
68
fmt = xargs + %w[ stree write -- ]
69
69
sh ( ruby_opt , "#{ files . shelljoin } | #{ fmt . shelljoin } " )
70
70
end
71
71
72
72
desc ( "Format `*.rbs`" )
73
73
multitask ( :"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 ]
75
75
inplace = /darwin|bsd/ =~ RUBY_PLATFORM ? [ "-i" , "" ] : %w[ -i ]
76
76
uuid = SecureRandom . uuid
77
77
Original file line number Diff line number Diff line change @@ -6,13 +6,16 @@ echo "Script started with $# arguments"
6
6
echo " Arguments: $* "
7
7
echo " Script location: $( dirname " $0 " ) "
8
8
9
- cd " $( dirname " $0 " ) /.."
10
- echo " Changed to directory: $( pwd ) "
9
+ cd -- " $( dirname " $0 " ) /.."
10
+ echo " Changed to directory: $PWD "
11
11
12
12
if [ $# -eq 0 ]; then
13
13
echo " Usage: $0 <file-with-paths> [additional-formatter-args...]"
14
14
echo " The file should contain one file path per line"
15
15
exit 1
16
16
fi
17
17
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