Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sunny/49519bb22c138dda910a3b431c1b2f04 to your computer and use it in GitHub Desktop.
Save sunny/49519bb22c138dda910a3b431c1b2f04 to your computer and use it in GitHub Desktop.
Add frozen string literal comment into generated files in Rails 7
# frozen_string_literal: true
# Via https://gist.github.com/ta1kt0me/6a7058d16621785d4f7038bde6cd3b98
module RailsGeneratorFrozenStringLiteralPrepend
RUBY_EXTENSIONS = %w[.rb .rake].freeze
def render
return super unless RUBY_EXTENSIONS.include?(File.extname(destination))
"# frozen_string_literal: true\n\n#{super}"
end
end
Thor::Actions::CreateFile.prepend RailsGeneratorFrozenStringLiteralPrepend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment