Ricardo Castañeda
Ricardo Castañeda

Reputation: 5812

Custom Rake copy file to current directory in Mac

Is it possible to make a rake command that copies a file from a Mac and saves it into current directory?

I've tried using cp commands but it doesn't work.

This is what I've tried:

namespace :generate do
     desc "Generate empty html5 index"
     task :index do
       #cp Dir['~/.rake/templates/index.html'], '.'
       # cp "~/.rake/templates/index.html ."

     end
   end

Upvotes: 1

Views: 122

Answers (1)

Ricardo Castañeda
Ricardo Castañeda

Reputation: 5812

I've just found the answer, I had to use sh command to execute shell commands in rake. Reference here

require 'fileutils'

namespace :generate do
  desc "Generate empty html5 index"
  task :index do
     sh %{ cp ~/.rake/templates/index.html . }
  end
end

Upvotes: 1

Related Questions