Method: Thor::Actions::InjectIntoFile#invoke!

Defined in:
lib/thor/actions/inject_into_file.rb

#invoke!Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/thor/actions/inject_into_file.rb', line 47

def invoke!
  say_status :invoke

  content = if @behavior == :after
    '\0' + replacement
  else
    replacement + '\0'
  end

  if exists?
    replace!(/#{flag}/, content, config[:force])
  else
    unless pretend?
      raise Thor::Error, "The file #{ destination } does not appear to exist"
    end
  end
end