Skip to content

Commit 003d113

Browse files
authored
Fix for #707
Try to replace text but skip overwritting file with pretend option
1 parent fb625b2 commit 003d113

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/thor/actions/inject_into_file.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,11 @@ def say_status(behavior, warning: nil, color: nil)
106106
# Adds the content to the file.
107107
#
108108
def replace!(regexp, string, force)
109-
return if pretend?
110109
content = File.read(destination)
111110
if force || !content.include?(replacement)
112111
success = content.gsub!(regexp, string)
113112

114-
File.open(destination, "wb") { |file| file.write(content) }
113+
File.open(destination, "wb") { |file| file.write(content) } unless pretend?
115114
success
116115
end
117116
end

0 commit comments

Comments
 (0)