From 04f07c1e661dae7a0501d075e104a52fce4b71b1 Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Tue, 23 May 2023 10:53:33 +1200 Subject: [PATCH] Fix `sqlite3` gsub in `Refinery::CmsGenerator` (#3530) I noticed when running `rails new -m https://www.refinerycms.com/t/edge` that it was mangling the `Gemfile` when the `sqlite3` line looked like: ```ruby gem 'sqlite3', '~> 1.4' ``` Instead of the expected: ```ruby gem 'sqlite3' ``` Our `gsub_file` instruction now captures the entire line and inserts it inside the `group :development, :test do` block. --- core/lib/generators/refinery/cms/cms_generator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/generators/refinery/cms/cms_generator.rb b/core/lib/generators/refinery/cms/cms_generator.rb index db1dcc11eb..b4a86e645d 100644 --- a/core/lib/generators/refinery/cms/cms_generator.rb +++ b/core/lib/generators/refinery/cms/cms_generator.rb @@ -62,8 +62,8 @@ def append_asset_pipeline! def append_gemfile! if destination_path.join('Gemfile').file? && destination_path.join('Gemfile').read !~ %r{group :development, :test do\n.+?gem 'sqlite3'\nend}m - gsub_file 'Gemfile', %q{gem 'sqlite3'}, %q{group :development, :test do - gem 'sqlite3' + gsub_file 'Gemfile', /(gem\ ['|"]sqlite3['|"].*)$/, %q{group :development, :test do + \1 end} end end