module Thor::Actions
def copy_file(source, *args, &block)
copy_file "doc/README"
copy_file "README", "doc/README"
==== Examples
:mode => :preserve, to preserve the file mode from the source.
config
destination
source
==== Parameters
the destination is not given it's assumed to be equal to the source.
Copies the file from the relative source to the relative destination. If
def copy_file(source, *args, &block) config = args.last.is_a?(Hash) ? args.pop : {} destination = args.first || source source = File.expand_path(find_in_source_paths(source.to_s)) resulting_destination = create_file destination, nil, config do content = File.binread(source) content = yield(content) if block content end if config[:mode] == :preserve mode = File.stat(source).mode chmod(resulting_destination, mode, config) end end