I have a Rakefile like this
task :clean do
sh 'rm ./foo'
end
I want to prevent it from reporting error when the file ‘foo’ does not exist. How to do that?
I think what I want is: Is there a way to check the file first and then decide what to do next.
For example:
file 'aaa' => 'bbb' do
sh 'cp bbb aaa'
end
This task depends on the existence of file ‘bbb’, so I want to know can I tell Rake that my task depends on the non-existence of file 'foo' ?
You can do this by extending rake a bit:
Rakefile:
unfile_rake_ext.rb:
And my console output:
Hope this helps.