Module: PDK::CLI::Exec
- Defined in:
- lib/pdk/cli/exec.rb,
lib/pdk/cli/exec/command.rb,
lib/pdk/cli/exec/interactive_command.rb
Defined Under Namespace
Classes: Command, InteractiveCommand
Class Method Summary
collapse
Class Method Details
.bundle(*args) ⇒ Object
42
43
44
45
46
|
# File 'lib/pdk/cli/exec.rb', line 42
def self.bundle(*args)
ensure_bin_present!(bundle_bin, 'bundler')
execute(bundle_bin, *args)
end
|
.bundle_bin ⇒ Object
48
49
50
51
52
53
|
# File 'lib/pdk/cli/exec.rb', line 48
def self.bundle_bin
bundle_bin = Gem.win_platform? ? 'bundle.bat' : 'bundle'
vendored_bin_path = File.join('private', 'ruby', PDK::Util::RubyVersion.active_ruby_version, 'bin', bundle_bin)
try_vendored_bin(vendored_bin_path, bundle_bin)
end
|
.ensure_bin_present!(bin_path, bin_name) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/pdk/cli/exec.rb', line 34
def self.ensure_bin_present!(bin_path, bin_name)
message = _('Unable to find `%{name}`. Check that it is installed and try again.') % {
name: bin_name,
}
raise PDK::CLI::FatalError, message unless TTY::Which.exist?(bin_path)
end
|
.execute(*cmd) ⇒ Object
18
19
20
|
# File 'lib/pdk/cli/exec.rb', line 18
def self.execute(*cmd)
Command.new(*cmd).execute!
end
|
.execute_interactive(*cmd) ⇒ Object
.execute_interactive_with_env(env, *cmd) ⇒ Object
30
31
32
|
# File 'lib/pdk/cli/exec.rb', line 30
def self.execute_interactive_with_env(env, *cmd)
InteractiveCommand.new(*cmd).tap { |c| c.environment = env }.execute!
end
|
.execute_with_env(env, *cmd) ⇒ Object
22
23
24
|
# File 'lib/pdk/cli/exec.rb', line 22
def self.execute_with_env(env, *cmd)
Command.new(*cmd).tap { |c| c.environment = env }.execute!
end
|
.try_vendored_bin(vendored_bin_path, fallback) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/pdk/cli/exec.rb', line 55
def self.try_vendored_bin(vendored_bin_path, fallback)
unless PDK::Util.package_install?
PDK.logger.debug(_("PDK package installation not found. Trying '%{fallback}' from the system PATH instead.") % {
fallback: fallback,
})
return fallback
end
vendored_bin_full_path = File.join(PDK::Util.pdk_package_basedir, vendored_bin_path)
unless File.exist?(vendored_bin_full_path)
PDK.logger.debug(_("Could not find '%{vendored_bin}' in PDK package. Trying '%{fallback}' from the system PATH instead.") % {
fallback: fallback,
vendored_bin: vendored_bin_full_path,
})
return fallback
end
PDK.logger.debug(_("Using '%{vendored_bin}' from PDK package.") % { vendored_bin: vendored_bin_full_path })
vendored_bin_full_path
end
|