Reputation: 6563
I would like to abort a rake task with custom exit code (to communicate to the executing shell script that a specific condition was met).
Rake task that succeeds returns 0 and fail always returns 1. Is there a way to make a custom code?
Upvotes: 2
Views: 2103
Reputation: 32335
The correct way would be to call exit
with the required exit code, which - unlike what you'd expect from other programming languages - does not actually exit the program immediately, instead it raises a SystemExit
exception that is in turn caught by Rake and handled correctly (by performing any required cleanups and then propagating the exit request with your status code up to the script that ran rake
).
Upvotes: 5