diff --git a/lib/generators/spina/tailwind_config_generator.rb b/lib/generators/spina/tailwind_config_generator.rb index ae2718aa5..ca9995957 100644 --- a/lib/generators/spina/tailwind_config_generator.rb +++ b/lib/generators/spina/tailwind_config_generator.rb @@ -2,14 +2,21 @@ module Spina class TailwindConfigGenerator < Rails::Generators::Base source_root File.expand_path("../templates", __FILE__) + CONFIG_FILE = "app/assets/config/spina/tailwind.config.js" + IGNORE_TEXT = <<~TEXT.chomp + # Ignore auto-generated Spina Tailwind CSS configuration + /#{CONFIG_FILE} + TEXT + def create_tailwind_config_file - filename = "app/assets/config/spina/tailwind.config.js" - template filename - insert_into_file ".gitignore", <<~TEXT + template CONFIG_FILE - # Ignore auto-generated Spina Tailwind CSS configuration - /#{filename} - TEXT + unless File.read(".gitignore").include?(IGNORE_TEXT) + append_to_file ".gitignore", <<~TEXT + \n + #{IGNORE_TEXT} + TEXT + end end end end