rails / jsbundling-rails

Bundle and transpile JavaScript in Rails with esbuild, rollup.js, or Webpack.
MIT License
831 stars 143 forks source link

Include .gitattributes when building the gem #193

Closed pokonski closed 1 month ago

pokonski commented 4 months ago

lib/install/bun/.gitattributes was missing from the final build of the gem. This was causing an error during installation when jsbundling-rails tried to copy its own .gitattributes into host project's root.

Dir["lib/**/*"] does not include files starting with a dot, so I replaced it with a method that does include them. Also stripped directories from the list because according to the specification, they are ignored anyway:

Only add files you can require to this list, not directories, etc. Directories are automatically stripped from this list when building a gem, other non-files cause an error.

Fixes https://github.com/rails/jsbundling-rails/issues/175

Proof:

Dir.glob("lib/**/*", File::FNM_DOTMATCH).any? { |path| path.include?(".gitattributes") }
=> true

vs

Dir["lib/**/*"].any? { |path| path.include?(".gitattributes") }
=> false