@@ -75,7 +75,10 @@ def remove_default_gem_files
75
75
def remove_default_bin_dev
76
76
bin_dev_path = File . join ( destination_root , "bin/dev" )
77
77
return unless File . exist? ( bin_dev_path )
78
+ return unless File . writable? ( bin_dev_path )
78
79
80
+ # Rails 7+ default bin/dev content
81
+ # If Rails changes this default, this comparison will safely fail and preserve the file
79
82
default_bin_dev = <<~RUBY . strip
80
83
#!/usr/bin/env ruby
81
84
exec "./bin/rails", "server", *ARGV
@@ -85,16 +88,17 @@ def remove_default_bin_dev
85
88
return unless current_content == default_bin_dev
86
89
87
90
puts Rainbow ( "🗑️ Removing default bin/dev file to avoid conflicts..." ) . yellow
88
- File . delete ( bin_dev_path )
91
+ FileUtils . rm_f ( bin_dev_path )
89
92
end
90
93
91
94
def remove_default_shakapacker_yml
92
95
config_path = File . join ( destination_root , "config/shakapacker.yml" )
93
96
return unless File . exist? ( config_path )
97
+ return unless File . writable? ( config_path )
94
98
return unless shakapacker_yml_matches_default? ( config_path )
95
99
96
100
puts Rainbow ( "🗑️ Removing default config/shakapacker.yml file to avoid conflicts..." ) . yellow
97
- File . delete ( config_path )
101
+ FileUtils . rm_f ( config_path )
98
102
end
99
103
100
104
def shakapacker_yml_matches_default? ( config_path )
@@ -108,9 +112,8 @@ def shakapacker_yml_matches_default?(config_path)
108
112
current_content = File . read ( config_path )
109
113
110
114
current_content == default_content
111
- rescue StandardError => e
115
+ rescue StandardError
112
116
# If we can't compare, don't delete - better safe than sorry
113
- puts Rainbow ( "⚠️ Could not verify shakapacker.yml: #{ e . message } " ) . yellow if options . verbose?
114
117
false
115
118
end
116
119
0 commit comments