Method: Confswap::Command#write_file

Defined in:
lib/confswap/command.rb

#write_file(output_file_contents, output_filename) ⇒ Object



115
116
117
118
119
120
121
122
123
124
# File 'lib/confswap/command.rb', line 115

def write_file output_file_contents, output_filename
  return File.write output_filename, output_file_contents unless File.exists? output_filename
  
  if File.exists? output_filename and force?
    puts "Overwriting #{output_filename}..."
    File.write output_filename, output_file_contents
  else
    puts "#{output_filename} already exists, use the --force flag to overwrite"
  end
end