Method: Thor::Actions#copy_file
- Defined in:
- lib/thor/actions/file_manipulation.rb
#copy_file(source, *args, &block) ⇒ Object
Examples
copy_file "README", "doc/README"
copy_file "doc/README"
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/thor/actions/file_manipulation.rb', line 21 def copy_file(source, *args, &block) config = args.last.is_a?(Hash) ? args.pop : {} destination = args.first || source source = File.(find_in_source_paths(source.to_s)) 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(destination, mode, config) end end |