lib/bundler/dependencies/cli/command.rb in bundler-dependencies-0.5.1 vs lib/bundler/dependencies/cli/command.rb in bundler-dependencies-0.6.0
- old
+ new
@@ -7,10 +7,11 @@
activejob activemodel activerecord activestorage activesupport railties
).freeze
def initialize(options)
@options = options
+ self.shell = Thor::Shell::Basic.new unless options.color?
end
no_commands do
def output
to_s
@@ -32,31 +33,43 @@
end
def path
return options.path if valid_gemfile?(options.path)
- SharedHelpers.chdir(File.dirname(options.path)) if options.path
+ dir = path_dir(options.path)
+ SharedHelpers.chdir(dir) if dir
SharedHelpers.default_lockfile
end
+ def path_dir(path)
+ return nil unless path
+
+ Dir.exist?(options.path) ? options.path : File.dirname(options.path)
+ end
+
def valid_gemfile?(path)
return false unless path && File.exist?(path)
- %w(Gemfile.lock gems.locked).include?(File.basename(path))
+ File.basename(path).end_with?('.lock', '.locked')
end
def without
(options.without || []).tap do |gems|
gems.concat(RAILS_GEMS) if options.without_rails?
end
end
+ def gems
+ @gems ||= graph.without(*without)
+ end
+
def warn(message)
say(message, %i(bold yellow))
end
def error(message)
- say(message, %i(bold red))
+ message = shell.send(:prepare_message, message, :red, :bold)
+ super(message)
end
end
end
end
end