| 1 |
# frozen_string_literal: true |
| 2 |
|
| 3 |
module Bundler |
| 4 |
class CLI::Check |
| 5 |
attr_reader :options |
| 6 |
|
| 7 |
def initialize(options) |
| 8 |
@options = options |
| 9 |
end |
| 10 |
|
| 11 |
def run |
| 12 |
Bundler.settings.set_command_option_if_given :path, options[:path] |
| 13 |
|
| 14 |
definition = Bundler.definition |
| 15 |
definition.validate_runtime! |
| 16 |
|
| 17 |
begin |
| 18 |
definition.resolve_only_locally! |
| 19 |
not_installed = definition.missing_specs |
| 20 |
rescue GemNotFound, GitError, SolveFailure |
| 21 |
Bundler.ui.error "Bundler can't satisfy your Gemfile's dependencies." |
| 22 |
Bundler.ui.warn "Install missing gems with `bundle install`." |
| 23 |
exit 1 |
| 24 |
end |
| 25 |
|
| 26 |
if not_installed.any? |
| 27 |
Bundler.ui.error "The following gems are missing" |
| 28 |
not_installed.each {|s| Bundler.ui.error " * #{s.name} (#{s.version})" } |
| 29 |
Bundler.ui.warn "Install missing gems with `bundle install`" |
| 30 |
exit 1 |
| 31 |
elsif !Bundler.default_lockfile.file? && Bundler.frozen_bundle? |
| 32 |
Bundler.ui.error "This bundle has been frozen, but there is no #{SharedHelpers.relative_lockfile_path} present" |
| 33 |
exit 1 |
| 34 |
else |
| 35 |
Bundler.load.lock(preserve_unknown_sections: true) unless options[:"dry-run"] |
| 36 |
Bundler.ui.info "The Gemfile's dependencies are satisfied" |
| 37 |
end |
| 38 |
end |
| 39 |
end |
| 40 |
end |