From 6c2f5dd3fd05c7185d5c03204862112abfd3a940 Mon Sep 17 00:00:00 2001 From: Derek Kniffin Date: Sun, 14 Aug 2016 23:17:31 -0400 Subject: [PATCH] Use the return value from the command to determine exit code --- lib/thor/base.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/thor/base.rb b/lib/thor/base.rb index 8cd418637..fc43d3bc6 100644 --- a/lib/thor/base.rb +++ b/lib/thor/base.rb @@ -437,7 +437,10 @@ def namespace(name = nil) # def start(given_args = ARGV, config = {}) config[:shell] ||= Thor::Base.shell.new - dispatch(nil, given_args.dup, nil, config) + command_return = dispatch(nil, given_args.dup, nil, config) + + # Use the return value from the command to determine exit code + exit(1) unless command_return rescue Thor::Error => e config[:debug] || ENV["THOR_DEBUG"] == "1" ? (raise e) : config[:shell].error(e.message) exit(1) if exit_on_failure?