Forked from ta1kt0me/add_frozen_string_literal_comment.rb
Last active
November 23, 2022 17:03
-
-
Save sunny/49519bb22c138dda910a3b431c1b2f04 to your computer and use it in GitHub Desktop.
Add frozen string literal comment into generated files in Rails 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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