summaryrefslogtreecommitdiff
path: root/lib/bundler/cli.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-04-04 17:01:19 +0200
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-04-19 21:09:12 +0900
commitcf9a2883fea3c28c8d869c72b1b407162a28e0b3 (patch)
tree99789b969cc63394e49ca145be3f456c339cb12f /lib/bundler/cli.rb
parente107f3f4cb2e11ef6fd46db21392a22fdab4eb2a (diff)
downloadbundler-cf9a2883fea3c28c8d869c72b1b407162a28e0b3.tar.gz
Prefer `require_relative` for internal requires
Due to the way rubygems monkey-patched require interacts with default gems, and given that bundler is a default gem, and that bundler manipulates the LOAD_PATH in very intricated ways, we can reduce the risk of "leaking" to a different copy of `bundler` by using `require_relative` for internal requires.
Diffstat (limited to 'lib/bundler/cli.rb')
-rw-r--r--lib/bundler/cli.rb58
1 files changed, 29 insertions, 29 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index a9c83e982f..5d5363aee8 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require "bundler/vendored_thor"
+require_relative "vendored_thor"
module Bundler
class CLI < Thor
- require "bundler/cli/common"
+ require_relative "cli/common"
package_name "Bundler"
@@ -138,7 +138,7 @@ module Bundler
D
method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
def init
- require "bundler/cli/init"
+ require_relative "cli/init"
Init.new(options.dup).run
end
@@ -156,7 +156,7 @@ module Bundler
"Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
map "c" => "check"
def check
- require "bundler/cli/check"
+ require_relative "cli/check"
Check.new(options).run
end
@@ -167,7 +167,7 @@ module Bundler
method_option "install", :type => :boolean, :banner =>
"Runs 'bundle install' after removing the gems from the Gemfile"
def remove(*gems)
- require "bundler/cli/remove"
+ require_relative "cli/remove"
Remove.new(gems, options).run
end
@@ -229,7 +229,7 @@ module Bundler
remembered_flag_deprecation(option)
end
- require "bundler/cli/install"
+ require_relative "cli/install"
Bundler.settings.temporary(:no_install => false) do
Install.new(options.dup).run
end
@@ -275,7 +275,7 @@ module Bundler
"Update everything."
def update(*gems)
SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
- require "bundler/cli/update"
+ require_relative "cli/update"
Bundler.settings.temporary(:no_install => false) do
Update.new(options, gems).run
end
@@ -311,7 +311,7 @@ module Bundler
Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`")
end
end
- require "bundler/cli/show"
+ require_relative "cli/show"
Show.new(options, gem_name).run
end
end
@@ -322,7 +322,7 @@ module Bundler
method_option "without-group", :type => :string, :banner => "print all gems except from a group"
method_option "paths", :type => :boolean, :banner => "print the path to each gem in the bundle"
def list
- require "bundler/cli/list"
+ require_relative "cli/list"
List.new(options).run
end
@@ -331,7 +331,7 @@ module Bundler
desc "info GEM [OPTIONS]", "Show information for the given gem"
method_option "path", :type => :boolean, :banner => "Print full path to gem"
def info(gem_name)
- require "bundler/cli/info"
+ require_relative "cli/info"
Info.new(options, gem_name).run
end
@@ -352,7 +352,7 @@ module Bundler
method_option "all", :type => :boolean, :banner =>
"Install binstubs for all gems"
def binstubs(*gems)
- require "bundler/cli/binstubs"
+ require_relative "cli/binstubs"
Binstubs.new(options, gems).run
end
@@ -368,7 +368,7 @@ module Bundler
method_option "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem"
method_option "strict", :type => :boolean, :banner => "Adds strict declaration of version to gem"
def add(*gems)
- require "bundler/cli/add"
+ require_relative "cli/add"
Add.new(options.dup, gems).run
end
@@ -404,7 +404,7 @@ module Bundler
method_option "only-explicit", :type => :boolean, :banner =>
"Only list gems specified in your Gemfile, not their dependencies"
def outdated(*gems)
- require "bundler/cli/outdated"
+ require_relative "cli/outdated"
Outdated.new(options, gems).run
end
@@ -419,7 +419,7 @@ module Bundler
method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
def cache
- require "bundler/cli/cache"
+ require_relative "cli/cache"
Cache.new(options).run
end
end
@@ -447,7 +447,7 @@ module Bundler
bundle without having to download any additional gems.
D
def package
- require "bundler/cli/package"
+ require_relative "cli/package"
Package.new(options).run
end
map %w[pack] => :package
@@ -462,7 +462,7 @@ module Bundler
D
map "e" => "exec"
def exec(*args)
- require "bundler/cli/exec"
+ require_relative "cli/exec"
Exec.new(options, args).run
end
@@ -478,19 +478,19 @@ module Bundler
will show the current value, as well as any superceded values and
where they were specified.
D
- require "bundler/cli/config"
+ require_relative "cli/config"
subcommand "config", Config
desc "open GEM", "Opens the source directory of the given bundled gem"
def open(name)
- require "bundler/cli/open"
+ require_relative "cli/open"
Open.new(options, name).run
end
unless Bundler.feature_flag.bundler_3_mode?
desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
def console(group = nil)
- require "bundler/cli/console"
+ require_relative "cli/console"
Console.new(options, group).run
end
end
@@ -538,7 +538,7 @@ module Bundler
method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
def viz
SharedHelpers.major_deprecation 2, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz"
- require "bundler/cli/viz"
+ require_relative "cli/viz"
Viz.new(options.dup).run
end
end
@@ -562,7 +562,7 @@ module Bundler
def gem_command.run(instance, args = [])
arity = 1 # name
- require "bundler/cli/gem"
+ require_relative "cli/gem"
cmd_args = args + [instance]
cmd_args.unshift(instance.options)
@@ -590,7 +590,7 @@ module Bundler
method_option "force", :type => :boolean, :default => false, :banner =>
"Forces clean even if --path is not set"
def clean
- require "bundler/cli/clean"
+ require_relative "cli/clean"
Clean.new(options.dup).run
end
@@ -598,7 +598,7 @@ module Bundler
method_option "ruby", :type => :boolean, :default => false, :banner =>
"only display ruby related platform information"
def platform
- require "bundler/cli/platform"
+ require_relative "cli/platform"
Platform.new(options).run
end
@@ -609,7 +609,7 @@ module Bundler
"Install gem into a bundler group"
def inject(name, version)
SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command"
- require "bundler/cli/inject"
+ require_relative "cli/inject"
Inject.new(options.dup, name, version).run
end
@@ -641,7 +641,7 @@ module Bundler
method_option "conservative", :type => :boolean, :banner =>
"If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
def lock
- require "bundler/cli/lock"
+ require_relative "cli/lock"
Lock.new(options).run
end
@@ -661,13 +661,13 @@ module Bundler
method_option "quiet", :type => :boolean, :banner =>
"Only output warnings and errors."
def doctor
- require "bundler/cli/doctor"
+ require_relative "cli/doctor"
Doctor.new(options).run
end
desc "issue", "Learn how to report an issue in Bundler"
def issue
- require "bundler/cli/issue"
+ require_relative "cli/issue"
Issue.new.run
end
@@ -678,12 +678,12 @@ module Bundler
checkout --force`.
D
def pristine(*gems)
- require "bundler/cli/pristine"
+ require_relative "cli/pristine"
Pristine.new(gems).run
end
if Bundler.feature_flag.plugins?
- require "bundler/cli/plugin"
+ require_relative "cli/plugin"
desc "plugin", "Manage the bundler plugins"
subcommand "plugin", Plugin
end