救援耙任务
我的 Rakefile 中有许多文件任务,看起来像
file 'task1' => 'dep' do
sh "some command"
end
还有
task :start => :next
task :last => :dep2
我想知道是否有一种方法可以在顶层拯救它,即说
begin
task :last => :dep2
rescue
# do something
end
而不是在每个 file
任务中这样做
file 'task1' => 'dep' do
begin
sh "some command"
rescue
# do something
end
end
是吗?可能的?
I have a number of file tasks in my Rakefile which look like
file 'task1' => 'dep' do
sh "some command"
end
There's also
task :start => :next
task :last => :dep2
I was wondering if there was a way of rescuing it on the top level, i.e. to say
begin
task :last => :dep2
rescue
# do something
end
rather than in every file
task do
file 'task1' => 'dep' do
begin
sh "some command"
rescue
# do something
end
end
Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,但您可以定义自定义方法来简化您的任务。
另外,请记住
:task2
依赖于:task1
并且:task1
可能引发异常,您应该在中处理错误:任务1
,不在:task2
中。No, but you can define a custom method to simplify your tasks.
Also, remember that is
:task2
depends on:task1
and:task1
can raise an exception, you should handle the error in:task1
, not in:task2
.