下面的文件任务不执行。它是一个简单的Rakefile的内容,如果它不存在,它将创建一个名为hello.txt
的文件。耙文件任务不起作用
task :default do
puts "before file task"
file "hello.txt" do
puts "in file task"
sh "touch hello.txt"
end
puts "after file task"
end
在其中Rake文件所在的目录shell提示运行rake
后,输出为:
before file task
after file task
和没有创建hello.txt
文件。
我不确定为什么文件任务不起作用,至于我的眼睛,Rakefile的文件任务部分的语法看起来很合理。我在这里做错了什么?
耙包括文件实用程序模块。所以你可以使用'mkdir','rmdir','cp','mv','chmod'和'touch'方法:)所以'sh“touch hello.txt”'给出和'触摸“hello.txt”,但后者不会出现 – mbigras