Skip to content

Commit

Permalink
Merge pull request #718 from bpo/fix-verbose-warnings
Browse files Browse the repository at this point in the history
🌈 Fix another warning about $thor_runner
  • Loading branch information
rafaelfranca authored Mar 6, 2020
2 parents 8ec6acb + 924b399 commit 0e5efb8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/thor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require_relative "thor/base"

class Thor
$thor_runner ||= false
class << self
# Allows for custom "Command" package naming.
#
Expand Down Expand Up @@ -398,7 +399,6 @@ def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable Me
# the namespace should be displayed as arguments.
#
def banner(command, namespace = nil, subcommand = false)
$thor_runner ||= false
command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |formatted_usage|
"#{basename} #{formatted_usage}"
end.join("\n")
Expand Down
3 changes: 3 additions & 0 deletions spec/fixtures/verbose.thor
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ $VERBOSE = true
require 'thor'

class Test < Thor
def self.exit_on_failure?
true
end
end

Test.start(ARGV)
6 changes: 6 additions & 0 deletions spec/no_warnings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@

expect(err).to be_empty
end

it "prints no warnings even when erroring" do
root = File.expand_path("..", __dir__)
_, err, = Open3.capture3("ruby -I #{root}/lib #{root}/spec/fixtures/verbose.thor noop")
expect(err).to_not match(/warning:/)
end
end

0 comments on commit 0e5efb8

Please sign in to comment.