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'


350
351
352
353
354
355
356
357
358
359
# File 'lib/thor/actions/file_manipulation.rb', line 350

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) || File.symlink?(path))
    require "fileutils"
    ::FileUtils.rm_rf(path)
  end
end