erb-formatter icon indicating copy to clipboard operation
erb-formatter copied to clipboard

Support globs for files to format

Open tmaier opened this issue 8 months ago • 1 comments

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

tmaier avatar Dec 13 '23 23:12 tmaier