nebulab / erb-formatter

Format ERB files with speed and precision
MIT License
135 stars 22 forks source link

Support globs for files to format #36

Closed tmaier closed 2 months ago

tmaier commented 8 months ago

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:

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
elia commented 8 months ago

In theory the double asterisk should already recurse subdirectories, maybe it's not enabled in your shell env?

For bash you should be able to enable it with shopt -s globstar, see https://askubuntu.com/a/1010708.