83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/thor/actions/inject_into_file.rb', line 83
def invoke!
content = if @behavior == :after
'\0' + replacement
else
replacement + '\0'
end
if exists?
if replace!(/#{flag}/, content, config[:force])
say_status(:invoke)
elsif @error_on_no_change
raise Thor::Error, "The content of #{destination} did not change"
elsif replacement_present?
say_status(:unchanged, color: :blue)
else
say_status(:unchanged, warning: WARNINGS[:unchanged_no_flag], color: :red)
end
else
unless pretend?
raise Thor::Error, "The file #{ destination } does not appear to exist"
end
end
end
|