Sha256: c6a50ec7bcd90d86daefde8daf9a7cedcb412e2eccb8f6b4221ed4a12ef01996

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

# Exit cleanly from an early interrupt
Signal.trap('INT') do
  Bundler.ui.debug("\n#{caller.join("\n")}") if defined?(Bundler)
  exit 1
end

require 'bundle-only/messages'

install_only = ARGV.to_a.map(&:to_sym)

if install_only.empty?
  exename = File.basename($PROGRAM_NAME)
  STDERR.puts "Usage: #{exename} group [group [...]]"
  exit 2
end

ENV['BUNDLE_IGNORE_CONFIG'] = 'true'
require 'bundler'

Bundler.configure

gemfile = Pathname.new(Bundler.default_gemfile).expand_path
builder = Bundler::Dsl.new
builder.eval_gemfile(gemfile)

all_groups = builder.dependencies.map(&:groups).flatten.uniq
groups_to_skip = all_groups - install_only
Bundler.settings.set_command_option :without, groups_to_skip
Bundler.settings.set_command_option :with, install_only

definition = builder.to_definition(Bundler.default_lockfile, {})
def definition.lock(*); end # never lock or preserve options
definition.validate_ruby!

Bundler.ui = Bundler::UI::Shell.new

installer = Bundler::Installer.install(Bundler.root, definition, system: true)

BundleOnly::Messages::Install.output_installation_complete_message(definition)
BundleOnly::Messages::Common.output_without_groups_message(:install)
BundleOnly::Messages::Common.output_post_install_messages installer.post_install_messages

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bundle-only-0.4.0 exe/bundle-only