Sha256: cfb050df3410d69e183237e2dcf080c30855ddda0d7261c0278f2fa72d5098ca

Contents?: true

Size: 1.78 KB

Versions: 86

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

module Bundler
  class CLI::Binstubs
    attr_reader :options, :gems
    def initialize(options, gems)
      @options = options
      @gems = gems
    end

    def run
      Bundler.definition.validate_runtime!
      path_option = options["path"]
      path_option = nil if path_option&.empty?
      Bundler.settings.set_command_option :bin, path_option if options["path"]
      Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
      installer = Installer.new(Bundler.root, Bundler.definition)

      installer_opts = {
        :force => options[:force],
        :binstubs_cmd => true,
        :all_platforms => options["all-platforms"],
      }

      if options[:all]
        raise InvalidOption, "Cannot specify --all with specific gems" unless gems.empty?
        @gems = Bundler.definition.specs.map(&:name)
        installer_opts.delete(:binstubs_cmd)
      elsif gems.empty?
        Bundler.ui.error "`bundle binstubs` needs at least one gem to run."
        exit 1
      end

      gems.each do |gem_name|
        spec = Bundler.definition.specs.find {|s| s.name == gem_name }
        unless spec
          raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(
            gem_name, Bundler.definition.specs
          )
        end

        if options[:standalone]
          if gem_name == "bundler"
            Bundler.ui.warn("Sorry, Bundler can only be run via RubyGems.") unless options[:all]
            next
          end

          Bundler.settings.temporary(:path => (Bundler.settings[:path] || Bundler.root)) do
            installer.generate_standalone_bundler_executable_stubs(spec, installer_opts)
          end
        else
          installer.generate_bundler_executable_stubs(spec, installer_opts)
        end
      end
    end
  end
end

Version data entries

86 entries across 86 versions & 4 rubygems

Version Path
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
direct7-0.0.13 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
direct7-0.0.12 vendor/bundle/ruby/2.7.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.2.8 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.2.7 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.2.6 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.2.5 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.2.4 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.2.3 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.2.2 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.2.1 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb
harbr-0.1.97 vendor/bundle/ruby/3.2.0/gems/bundler-2.4.21/lib/bundler/cli/binstubs.rb