lib/soaspec/exe_helpers.rb in soaspec-0.2.19 vs lib/soaspec/exe_helpers.rb in soaspec-0.2.20

- old
+ new

@@ -43,21 +43,28 @@ end # @param [String] filename Name of the file to create # @param [String] content Content to place inside file # @param [Boolean] ignore_if_present Don't complain if file is present + # @return [String] String describing if file created or not def create_file(filename: nil, content: nil, ignore_if_present: false, erb: true) raise 'Need to pass filename' unless filename content ||= retrieve_contents(filename, erb) create_folder File.split(filename).first - if File.exist? filename - old_content = File.read(filename) - warn "!! #{filename} already exists and differs from template" if old_content != content && !ignore_if_present - else - File.open(filename, 'w') { |f| f.puts content } - puts 'Created: ' + filename - end + msg = if File.exist? filename + old_content = File.read(filename) + if old_content != content && !ignore_if_present + "!! #{filename} already exists and differs from template" + else + "#{filename} already exists" + end + else + File.open(filename, 'w') { |f| f.puts content } + "Created: #{filename}" + end + puts msg + msg end # Create folder if there's not a file already there. # Will create parent folder if necessary. # @param [String] folder Folder to create