Method: Thor::Actions#remove_file

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

#remove_file(path, config = {}) ⇒ Object Also known as: remove_dir

Removes a file at the given location.

Parameters

path<String>

path of the file to be changed

config<Hash>

give :verbose => false to not log the status.

Example

remove_file 'README'
remove_file 'app/controllers/application_controller.rb'


318
319
320
321
322
323
324
325
326
327
# File 'lib/thor/actions/file_manipulation.rb', line 318

def remove_file(path, config = {})
  return unless behavior == :invoke
  path = File.expand_path(path, destination_root)

  say_status :remove, relative_to_original_destination_root(path), config.fetch(:verbose, true)
  if !options[:pretend] && File.exist?(path)
    require "fileutils"
    ::FileUtils.rm_rf(path)
  end
end