Friday, March 30, 2012

Things you should have in your rakefiles

Ensure that stdout and stderr output is properly ordered and not neatly separated: $stdout.sync=true $stderr.sync=true

Always print stack trace on error instead of only if --trace option was given: Rake.application.options.trace = true

Update 2012-04-10: More intrusive variant - enable stack trace on error but not progress messages: module Rake class Application def standard_exception_handling begin yield rescue SystemExit => ex # Exit silently with current status raise rescue OptionParser::InvalidOption => ex # Exit silently exit(false) rescue Exception => ex # Exit with error message $stderr.puts "Exception: #{ex.message}" $stderr.puts ex.backtrace.join("\n") exit(false) end end end end

Don't truncate rake -T output. Alternative to fiddling with environment variables: Rake.application.terminal_columns = 999

No comments:

Post a Comment