erb-formatter
erb-formatter copied to clipboard
Support globs for files to format
I want to use a tool called "erb-format" to format all my *.html.erb
and *.turbo_stream.erb
files.
The issue is, it supports globs just poorly. One would need to run the following to format all the files:
-
bin/erb-format **/*.{html,turbo_stream}.erb --write
-
bin/erb-format **/**/*.{html,turbo_stream}.erb --write
-
bin/erb-format **/**/**/*.{html,turbo_stream}.erb --write
-
bin/erb-format **/**/**/**/*.{html,turbo_stream}.erb --write
- ...
When any of them would not find a file, it raises an error like No such file or directory @ rb_sysopen - app/**/*.turbo_stream.erb (Errno::ENOENT)
I think Dir.glob
could solve this...
files =
Dir.glob(@argv).map do |filename|
[filename, File.read(filename)]
end