summaryrefslogtreecommitdiff
path: root/lib/bundler/vendor/thor
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bundler/vendor/thor')
-rw-r--r--lib/bundler/vendor/thor/lib/thor.rb7
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions.rb1
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/directory.rb22
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb10
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb25
-rw-r--r--lib/bundler/vendor/thor/lib/thor/base.rb18
-rw-r--r--lib/bundler/vendor/thor/lib/thor/command.rb35
-rw-r--r--lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb129
-rw-r--r--lib/bundler/vendor/thor/lib/thor/error.rb32
-rw-r--r--lib/bundler/vendor/thor/lib/thor/invocation.rb1
-rw-r--r--lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb12
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/arguments.rb2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/option.rb14
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/options.rb16
-rw-r--r--lib/bundler/vendor/thor/lib/thor/rake_compat.rb1
-rw-r--r--lib/bundler/vendor/thor/lib/thor/runner.rb2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/color.rb6
18 files changed, 118 insertions, 217 deletions
diff --git a/lib/bundler/vendor/thor/lib/thor.rb b/lib/bundler/vendor/thor/lib/thor.rb
index 395fad28eb..f2a03388cc 100644
--- a/lib/bundler/vendor/thor/lib/thor.rb
+++ b/lib/bundler/vendor/thor/lib/thor.rb
@@ -175,7 +175,7 @@ class Bundler::Thor
handle_no_command_error(meth) unless command
shell.say "Usage:"
- shell.say " #{banner(command)}"
+ shell.say " #{banner(command).split("\n").join("\n ")}"
shell.say
class_options_help(shell, nil => command.options.values)
if command.long_description
@@ -398,7 +398,10 @@ class Bundler::Thor
# the namespace should be displayed as arguments.
#
def banner(command, namespace = nil, subcommand = false)
- "#{basename} #{command.formatted_usage(self, $thor_runner, subcommand)}"
+ $thor_runner ||= false
+ command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |formatted_usage|
+ "#{basename} #{formatted_usage}"
+ end.join("\n")
end
def baseclass #:nodoc:
diff --git a/lib/bundler/vendor/thor/lib/thor/actions.rb b/lib/bundler/vendor/thor/lib/thor/actions.rb
index 5681d5a7c6..39ce67e142 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions.rb
@@ -12,6 +12,7 @@ class Bundler::Thor
attr_accessor :behavior
def self.included(base) #:nodoc:
+ super(base)
base.extend ClassMethods
end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/directory.rb b/lib/bundler/vendor/thor/lib/thor/actions/directory.rb
index 03c97bf630..d37327a139 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/directory.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/directory.rb
@@ -56,7 +56,7 @@ class Bundler::Thor
attr_reader :source
def initialize(base, source, destination = nil, config = {}, &block)
- @source = File.expand_path(base.find_in_source_paths(source.to_s))
+ @source = File.expand_path(Dir[Util.escape_globs(base.find_in_source_paths(source.to_s))].first)
@block = block
super(base, destination, {:recursive => true}.merge(config))
end
@@ -96,22 +96,12 @@ class Bundler::Thor
end
end
- if RUBY_VERSION < "2.0"
- def file_level_lookup(previous_lookup)
- File.join(previous_lookup, "{*,.[a-z]*}")
- end
-
- def files(lookup)
- Dir[lookup]
- end
- else
- def file_level_lookup(previous_lookup)
- File.join(previous_lookup, "*")
- end
+ def file_level_lookup(previous_lookup)
+ File.join(previous_lookup, "*")
+ end
- def files(lookup)
- Dir.glob(lookup, File::FNM_DOTMATCH)
- end
+ def files(lookup)
+ Dir.glob(lookup, File::FNM_DOTMATCH)
end
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
index cc29db05a8..afdbd53dd0 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
@@ -23,14 +23,14 @@ class Bundler::Thor
destination = args.first || source
source = File.expand_path(find_in_source_paths(source.to_s))
- create_file destination, nil, config do
+ resulting_destination = create_file destination, nil, config do
content = File.binread(source)
content = yield(content) if block
content
end
if config[:mode] == :preserve
mode = File.stat(source).mode
- chmod(destination, mode, config)
+ chmod(resulting_destination, mode, config)
end
end
@@ -80,14 +80,14 @@ class Bundler::Thor
config = args.last.is_a?(Hash) ? args.pop : {}
destination = args.first
- if source =~ %r{^https?\://}
+ render = if source =~ %r{^https?\://}
require "open-uri"
+ URI.send(:open, source) { |input| input.binmode.read }
else
source = File.expand_path(find_in_source_paths(source.to_s))
+ open(source) { |input| input.binmode.read }
end
- render = open(source) { |input| input.binmode.read }
-
destination ||= if block_given?
block.arity == 1 ? yield(render) : yield
else
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb b/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
index cf651a4e78..09ce0864f0 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
@@ -21,9 +21,14 @@ class Bundler::Thor
# gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
# end
#
+ WARNINGS = { unchanged_no_flag: 'File unchanged! The supplied flag value not found!' }
+
def insert_into_file(destination, *args, &block)
data = block_given? ? block : args.shift
- config = args.shift
+
+ config = args.shift || {}
+ config[:after] = /\z/ unless config.key?(:before) || config.key?(:after)
+
action InjectIntoFile.new(self, destination, data, config)
end
alias_method :inject_into_file, :insert_into_file
@@ -45,8 +50,6 @@ class Bundler::Thor
end
def invoke!
- say_status :invoke
-
content = if @behavior == :after
'\0' + replacement
else
@@ -54,7 +57,11 @@ class Bundler::Thor
end
if exists?
- replace!(/#{flag}/, content, config[:force])
+ if replace!(/#{flag}/, content, config[:force])
+ say_status(:invoke)
+ else
+ say_status(:unchanged, warning: WARNINGS[:unchanged_no_flag], color: :red)
+ end
else
unless pretend?
raise Bundler::Thor::Error, "The file #{ destination } does not appear to exist"
@@ -78,7 +85,7 @@ class Bundler::Thor
protected
- def say_status(behavior)
+ def say_status(behavior, warning: nil, color: nil)
status = if behavior == :invoke
if flag == /\A/
:prepend
@@ -87,11 +94,13 @@ class Bundler::Thor
else
:insert
end
+ elsif warning
+ warning
else
:subtract
end
- super(status, config[:verbose])
+ super(status, (color || config[:verbose]))
end
# Adds the content to the file.
@@ -100,8 +109,10 @@ class Bundler::Thor
return if pretend?
content = File.read(destination)
if force || !content.include?(replacement)
- content.gsub!(regexp, string)
+ success = content.gsub!(regexp, string)
+
File.open(destination, "wb") { |file| file.write(content) }
+ success
end
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/base.rb b/lib/bundler/vendor/thor/lib/thor/base.rb
index 7d7cd3b5fe..6089fd3dc4 100644
--- a/lib/bundler/vendor/thor/lib/thor/base.rb
+++ b/lib/bundler/vendor/thor/lib/thor/base.rb
@@ -1,6 +1,5 @@
require_relative "command"
require_relative "core_ext/hash_with_indifferent_access"
-require_relative "core_ext/ordered_hash"
require_relative "error"
require_relative "invocation"
require_relative "parser"
@@ -89,6 +88,7 @@ class Bundler::Thor
class << self
def included(base) #:nodoc:
+ super(base)
base.extend ClassMethods
base.send :include, Invocation
base.send :include, Shell
@@ -353,22 +353,22 @@ class Bundler::Thor
# Returns the commands for this Bundler::Thor class.
#
# ==== Returns
- # OrderedHash:: An ordered hash with commands names as keys and Bundler::Thor::Command
- # objects as values.
+ # Hash:: An ordered hash with commands names as keys and Bundler::Thor::Command
+ # objects as values.
#
def commands
- @commands ||= Bundler::Thor::CoreExt::OrderedHash.new
+ @commands ||= Hash.new
end
alias_method :tasks, :commands
# Returns the commands for this Bundler::Thor class and all subclasses.
#
# ==== Returns
- # OrderedHash:: An ordered hash with commands names as keys and Bundler::Thor::Command
- # objects as values.
+ # Hash:: An ordered hash with commands names as keys and Bundler::Thor::Command
+ # objects as values.
#
def all_commands
- @all_commands ||= from_superclass(:all_commands, Bundler::Thor::CoreExt::OrderedHash.new)
+ @all_commands ||= from_superclass(:all_commands, Hash.new)
@all_commands.merge!(commands)
end
alias_method :all_tasks, :all_commands
@@ -502,7 +502,7 @@ class Bundler::Thor
msg = "ERROR: \"#{basename} #{name}\" was called with ".dup
msg << "no arguments" if args.empty?
msg << "arguments " << args.inspect unless args.empty?
- msg << "\nUsage: #{banner(command).inspect}"
+ msg << "\nUsage: \"#{banner(command).split("\n").join("\"\n \"")}\""
raise InvocationError, msg
end
@@ -596,6 +596,7 @@ class Bundler::Thor
# Everytime someone inherits from a Bundler::Thor class, register the klass
# and file into baseclass.
def inherited(klass)
+ super(klass)
Bundler::Thor::Base.register_klass_file(klass)
klass.instance_variable_set(:@no_commands, false)
end
@@ -603,6 +604,7 @@ class Bundler::Thor
# Fire this callback whenever a method is added. Added methods are
# tracked as commands by invoking the create_command method.
def method_added(meth)
+ super(meth)
meth = meth.to_s
if meth == "initialize"
diff --git a/lib/bundler/vendor/thor/lib/thor/command.rb b/lib/bundler/vendor/thor/lib/thor/command.rb
index c636948e5d..040c971c0c 100644
--- a/lib/bundler/vendor/thor/lib/thor/command.rb
+++ b/lib/bundler/vendor/thor/lib/thor/command.rb
@@ -49,24 +49,32 @@ class Bundler::Thor
formatted ||= "".dup
- # Add usage with required arguments
- formatted << if klass && !klass.arguments.empty?
- usage.to_s.gsub(/^#{name}/) do |match|
- match << " " << klass.arguments.map(&:usage).compact.join(" ")
- end
- else
- usage.to_s
- end
+ Array(usage).map do |specific_usage|
+ formatted_specific_usage = formatted
- # Add required options
- formatted << " #{required_options}"
+ formatted_specific_usage += required_arguments_for(klass, specific_usage)
- # Strip and go!
- formatted.strip
+ # Add required options
+ formatted_specific_usage += " #{required_options}"
+
+ # Strip and go!
+ formatted_specific_usage.strip
+ end.join("\n")
end
protected
+ # Add usage with required arguments
+ def required_arguments_for(klass, usage)
+ if klass && !klass.arguments.empty?
+ usage.to_s.gsub(/^#{name}/) do |match|
+ match << " " << klass.arguments.map(&:usage).compact.join(" ")
+ end
+ else
+ usage.to_s
+ end
+ end
+
def not_debugging?(instance)
!(instance.class.respond_to?(:debugging) && instance.class.debugging)
end
@@ -97,8 +105,7 @@ class Bundler::Thor
def handle_argument_error?(instance, error, caller)
not_debugging?(instance) && (error.message =~ /wrong number of arguments/ || error.message =~ /given \d*, expected \d*/) && begin
saned = sans_backtrace(error.backtrace, caller)
- # Ruby 1.9 always include the called method in the backtrace
- saned.empty? || (saned.size == 1 && RUBY_VERSION >= "1.9")
+ saned.empty? || saned.size == 1
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb b/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb
deleted file mode 100644
index 76f1e43c65..0000000000
--- a/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb
+++ /dev/null
@@ -1,129 +0,0 @@
-class Bundler::Thor
- module CoreExt
- class OrderedHash < ::Hash
- if RUBY_VERSION < "1.9"
- def initialize(*args, &block)
- super
- @keys = []
- end
-
- def initialize_copy(other)
- super
- # make a deep copy of keys
- @keys = other.keys
- end
-
- def []=(key, value)
- @keys << key unless key?(key)
- super
- end
-
- def delete(key)
- if key? key
- index = @keys.index(key)
- @keys.delete_at index
- end
- super
- end
-
- def delete_if
- super
- sync_keys!
- self
- end
-
- alias_method :reject!, :delete_if
-
- def reject(&block)
- dup.reject!(&block)
- end
-
- def keys
- @keys.dup
- end
-
- def values
- @keys.map { |key| self[key] }
- end
-
- def to_hash
- self
- end
-
- def to_a
- @keys.map { |key| [key, self[key]] }
- end
-
- def each_key
- return to_enum(:each_key) unless block_given?
- @keys.each { |key| yield(key) }
- self
- end
-
- def each_value
- return to_enum(:each_value) unless block_given?
- @keys.each { |key| yield(self[key]) }
- self
- end
-
- def each
- return to_enum(:each) unless block_given?
- @keys.each { |key| yield([key, self[key]]) }
- self
- end
-
- def each_pair
- return to_enum(:each_pair) unless block_given?
- @keys.each { |key| yield(key, self[key]) }
- self
- end
-
- alias_method :select, :find_all
-
- def clear
- super
- @keys.clear
- self
- end
-
- def shift
- k = @keys.first
- v = delete(k)
- [k, v]
- end
-
- def merge!(other_hash)
- if block_given?
- other_hash.each { |k, v| self[k] = key?(k) ? yield(k, self[k], v) : v }
- else
- other_hash.each { |k, v| self[k] = v }
- end
- self
- end
-
- alias_method :update, :merge!
-
- def merge(other_hash, &block)
- dup.merge!(other_hash, &block)
- end
-
- # When replacing with another hash, the initial order of our keys must come from the other hash -ordered or not.
- def replace(other)
- super
- @keys = other.keys
- self
- end
-
- def inspect
- "#<#{self.class} #{super}>"
- end
-
- private
-
- def sync_keys!
- @keys.delete_if { |k| !key?(k) }
- end
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/lib/thor/error.rb b/lib/bundler/vendor/thor/lib/thor/error.rb
index 16c68294e4..1553afd201 100644
--- a/lib/bundler/vendor/thor/lib/thor/error.rb
+++ b/lib/bundler/vendor/thor/lib/thor/error.rb
@@ -1,22 +1,18 @@
class Bundler::Thor
- Correctable =
- begin
- require 'did_you_mean'
-
- # In order to support versions of Ruby that don't have keyword
- # arguments, we need our own spell checker class that doesn't take key
- # words. Even though this code wouldn't be hit because of the check
- # above, it's still necessary because the interpreter would otherwise be
- # unable to parse the file.
- class NoKwargSpellChecker < DidYouMean::SpellChecker # :nodoc:
- def initialize(dictionary)
- @dictionary = dictionary
- end
- end
-
- DidYouMean::Correctable
- rescue LoadError, NameError
- end
+ Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable)
+ # In order to support versions of Ruby that don't have keyword
+ # arguments, we need our own spell checker class that doesn't take key
+ # words. Even though this code wouldn't be hit because of the check
+ # above, it's still necessary because the interpreter would otherwise be
+ # unable to parse the file.
+ class NoKwargSpellChecker < DidYouMean::SpellChecker # :nodoc:
+ def initialize(dictionary)
+ @dictionary = dictionary
+ end
+ end
+
+ DidYouMean::Correctable
+ end
# Bundler::Thor::Error is raised when it's caused by wrong usage of thor classes. Those
# errors have their backtrace suppressed and are nicely shown to the user.
diff --git a/lib/bundler/vendor/thor/lib/thor/invocation.rb b/lib/bundler/vendor/thor/lib/thor/invocation.rb
index 866d2212a7..248a466f8e 100644
--- a/lib/bundler/vendor/thor/lib/thor/invocation.rb
+++ b/lib/bundler/vendor/thor/lib/thor/invocation.rb
@@ -1,6 +1,7 @@
class Bundler::Thor
module Invocation
def self.included(base) #:nodoc:
+ super(base)
base.extend ClassMethods
end
diff --git a/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb b/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb
index 0adb2b3137..fe3d7c998f 100644
--- a/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb
+++ b/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb
@@ -24,7 +24,7 @@ class Bundler::Thor
$stdin.gets
else
# Lazy-load io/console since it is gem-ified as of 2.3
- require "io/console" if RUBY_VERSION > "1.9.2"
+ require "io/console"
$stdin.noecho(&:gets)
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb b/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
index dd39cff35d..120eadd06a 100644
--- a/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
+++ b/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
@@ -1,19 +1,19 @@
-begin
- require "readline"
-rescue LoadError
-end
-
class Bundler::Thor
module LineEditor
class Readline < Basic
def self.available?
+ begin
+ require "readline"
+ rescue LoadError
+ end
+
Object.const_defined?(:Readline)
end
def readline
if echo?
::Readline.completion_append_character = nil
- # Ruby 1.8.7 does not allow Readline.completion_proc= to receive nil.
+ # rb-readline does not allow Readline.completion_proc= to receive nil.
if complete = completion_proc
::Readline.completion_proc = complete
end
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb b/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
index 1fd790f4b7..a17a3fcf22 100644
--- a/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
@@ -9,7 +9,7 @@ class Bundler::Thor
arguments = []
args.each do |item|
- break if item =~ /^-/
+ break if item.is_a?(String) && item =~ /^-/
arguments << item
end
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/option.rb b/lib/bundler/vendor/thor/lib/thor/parser/option.rb
index 85169b56c8..0ddd472b43 100644
--- a/lib/bundler/vendor/thor/lib/thor/parser/option.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/option.rb
@@ -1,17 +1,18 @@
class Bundler::Thor
class Option < Argument #:nodoc:
- attr_reader :aliases, :group, :lazy_default, :hide
+ attr_reader :aliases, :group, :lazy_default, :hide, :repeatable
VALID_TYPES = [:boolean, :numeric, :hash, :array, :string]
def initialize(name, options = {})
@check_default_type = options[:check_default_type]
options[:required] = false unless options.key?(:required)
+ @repeatable = options.fetch(:repeatable, false)
super
- @lazy_default = options[:lazy_default]
- @group = options[:group].to_s.capitalize if options[:group]
- @aliases = Array(options[:aliases])
- @hide = options[:hide]
+ @lazy_default = options[:lazy_default]
+ @group = options[:group].to_s.capitalize if options[:group]
+ @aliases = Array(options[:aliases])
+ @hide = options[:hide]
end
# This parse quick options given as method_options. It makes several
@@ -128,7 +129,8 @@ class Bundler::Thor
@default.class.name.downcase.to_sym
end
- raise ArgumentError, "Expected #{@type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})" unless default_type == @type
+ expected_type = (@repeatable && @type != :hash) ? :array : @type
+ raise ArgumentError, "Expected #{expected_type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})" unless default_type == expected_type
end
def dasherized?
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/options.rb b/lib/bundler/vendor/thor/lib/thor/parser/options.rb
index 179f4fa015..6d1342ee3c 100644
--- a/lib/bundler/vendor/thor/lib/thor/parser/options.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/options.rb
@@ -97,7 +97,8 @@ class Bundler::Thor
switch = normalize_switch(switch)
option = switch_option(switch)
- @assigns[option.human_name] = parse_peek(switch, option)
+ result = parse_peek(switch, option)
+ assign_result!(option, result)
elsif @stop_on_unknown
@parsing_options = false
@extra << shifted
@@ -132,6 +133,15 @@ class Bundler::Thor
protected
+ def assign_result!(option, result)
+ if option.repeatable && option.type == :hash
+ (@assigns[option.human_name] ||= {}).merge!(result)
+ elsif option.repeatable
+ (@assigns[option.human_name] ||= []) << result
+ else
+ @assigns[option.human_name] = result
+ end
+ end
# Check if the current value in peek is a registered switch.
#
# Two booleans are returned. The first is true if the current value
@@ -161,7 +171,7 @@ class Bundler::Thor
end
def switch?(arg)
- switch_option(normalize_switch(arg))
+ !switch_option(normalize_switch(arg)).nil?
end
def switch_option(arg)
@@ -194,7 +204,7 @@ class Bundler::Thor
shift
false
else
- !no_or_skip?(switch)
+ @switches.key?(switch) || !no_or_skip?(switch)
end
else
@switches.key?(switch) || !no_or_skip?(switch)
diff --git a/lib/bundler/vendor/thor/lib/thor/rake_compat.rb b/lib/bundler/vendor/thor/lib/thor/rake_compat.rb
index 60282e2991..f8f86372cc 100644
--- a/lib/bundler/vendor/thor/lib/thor/rake_compat.rb
+++ b/lib/bundler/vendor/thor/lib/thor/rake_compat.rb
@@ -25,6 +25,7 @@ class Bundler::Thor
end
def self.included(base)
+ super(base)
# Hack. Make rakefile point to invoker, so rdoc task is generated properly.
rakefile = File.basename(caller[0].match(/(.*):\d+/)[1])
Rake.application.instance_variable_set(:@rakefile, rakefile)
diff --git a/lib/bundler/vendor/thor/lib/thor/runner.rb b/lib/bundler/vendor/thor/lib/thor/runner.rb
index ed44853a00..48d33d7ac3 100644
--- a/lib/bundler/vendor/thor/lib/thor/runner.rb
+++ b/lib/bundler/vendor/thor/lib/thor/runner.rb
@@ -7,6 +7,8 @@ require "digest/md5"
require "pathname"
class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLength
+ autoload :OpenURI, "open-uri"
+
map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
def self.banner(command, all = false, subcommand = false)
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/color.rb b/lib/bundler/vendor/thor/lib/thor/shell/color.rb
index 6c821d4a09..29f280202d 100644
--- a/lib/bundler/vendor/thor/lib/thor/shell/color.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell/color.rb
@@ -97,7 +97,11 @@ class Bundler::Thor
protected
def can_display_colors?
- stdout.tty?
+ stdout.tty? && !are_colors_disabled?
+ end
+
+ def are_colors_disabled?
+ !ENV['NO_COLOR'].nil?
end
# Overwrite show_diff to show diff with colors if Diff::LCS is