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
38
39
40
41
42
|
# File 'lib/pdk/cli/exec.rb', line 38
def self.bundle(*args)
ensure_bin_present!(bundle_bin, 'bundler')
execute(bundle_bin, *args)
end
|
.bundle_bin ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/pdk/cli/exec.rb', line 44
def self.bundle_bin
require 'pdk/util/ruby_version'
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
28
29
30
31
32
33
34
35
36
|
# File 'lib/pdk/cli/exec.rb', line 28
def self.ensure_bin_present!(bin_path, bin_name)
require 'tty-which'
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
4
5
6
7
8
|
# File 'lib/pdk/cli/exec.rb', line 4
def self.execute(*cmd)
require 'pdk/cli/exec/command'
Command.new(*cmd).execute!
end
|
.execute_interactive(*cmd) ⇒ Object
16
17
18
19
20
|
# File 'lib/pdk/cli/exec.rb', line 16
def self.execute_interactive(*cmd)
require 'pdk/cli/exec/interactive_command'
InteractiveCommand.new(*cmd).execute!
end
|
.execute_interactive_with_env(env, *cmd) ⇒ Object
22
23
24
25
26
|
# File 'lib/pdk/cli/exec.rb', line 22
def self.execute_interactive_with_env(env, *cmd)
require 'pdk/cli/exec/interactive_command'
InteractiveCommand.new(*cmd).tap { |c| c.environment = env }.execute!
end
|
.execute_with_env(env, *cmd) ⇒ Object
10
11
12
13
14
|
# File 'lib/pdk/cli/exec.rb', line 10
def self.execute_with_env(env, *cmd)
require 'pdk/cli/exec/command'
Command.new(*cmd).tap { |c| c.environment = env }.execute!
end
|
.try_vendored_bin(vendored_bin_path, fallback) ⇒ Object
53
54
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 53
def self.try_vendored_bin(vendored_bin_path, fallback)
require 'pdk/util'
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
|