Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix uninitialized global variable warning #686

Merged
merged 1 commit into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/thor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ 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
10 changes: 10 additions & 0 deletions spec/fixtures/verbose.thor
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/ruby

$VERBOSE = true

require 'thor'

class Test < Thor
end

Test.start(ARGV)
10 changes: 10 additions & 0 deletions spec/no_warnings_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require "open3"

context "when $VERBOSE is enabled" do
it "prints no warnings" do
root = File.expand_path("..", __dir__)
_, err, _ = Open3.capture3("ruby -I #{root}/lib #{root}/spec/fixtures/verbose.thor")

expect(err).to be_empty
end
end