Module: PDK::CLI::Exec
- Defined in:
- lib/pdk/cli/exec.rb
Defined Under Namespace
Classes: Command
Class Method Summary collapse
- .bundle(*args) ⇒ Object
- .bundle_bin ⇒ Object
- .ensure_bin_present!(bin_path, bin_name) ⇒ Object
- .execute(*cmd) ⇒ Object
- .git(*args) ⇒ Object
- .git_bin ⇒ Object
- .git_bindir ⇒ Object
- .try_vendored_bin(vendored_bin_path, fallback) ⇒ Object
Class Method Details
.bundle(*args) ⇒ Object
41 42 43 44 45 |
# File 'lib/pdk/cli/exec.rb', line 41 def self.bundle(*args) ensure_bin_present!(bundle_bin, 'bundler') execute(bundle_bin, *args) end |
.bundle_bin ⇒ Object
47 48 49 50 51 52 |
# File 'lib/pdk/cli/exec.rb', line 47 def self.bundle_bin bundle_bin = Gem.win_platform? ? 'bundle.bat' : 'bundle' vendored_bin_path = File.join('private', 'ruby', '2.1.9', 'bin', bundle_bin) try_vendored_bin(vendored_bin_path, bundle_bin) end |
.ensure_bin_present!(bin_path, bin_name) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/pdk/cli/exec.rb', line 16 def self.ensure_bin_present!(bin_path, bin_name) = _('Unable to find `%{name}`. Check that it is installed and try again.') % { name: bin_name, } raise PDK::CLI::FatalError, unless TTY::Which.exist?(bin_path) end |
.execute(*cmd) ⇒ Object
12 13 14 |
# File 'lib/pdk/cli/exec.rb', line 12 def self.execute(*cmd) Command.new(*cmd).execute! end |
.git(*args) ⇒ Object
35 36 37 38 39 |
# File 'lib/pdk/cli/exec.rb', line 35 def self.git(*args) ensure_bin_present!(git_bin, 'git') execute(git_bin, *args) end |
.git_bin ⇒ Object
28 29 30 31 32 33 |
# File 'lib/pdk/cli/exec.rb', line 28 def self.git_bin git_bin = Gem.win_platform? ? 'git.exe' : 'git' vendored_bin_path = File.join(git_bindir, git_bin) try_vendored_bin(vendored_bin_path, git_bin) end |
.git_bindir ⇒ Object
24 25 26 |
# File 'lib/pdk/cli/exec.rb', line 24 def self.git_bindir @git_dir ||= File.join('private', 'git', Gem.win_platform? ? 'cmd' : 'bin') end |
.try_vendored_bin(vendored_bin_path, fallback) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/pdk/cli/exec.rb', line 54 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 if File.exist?(File.join(PDK::Util.pdk_package_basedir, vendored_bin_path)) PDK.logger.debug(_("Using '%{vendored_bin_path}' from PDK package") % { vendored_bin_path: vendored_bin_path }) File.join(PDK::Util.pdk_package_basedir, vendored_bin_path) else PDK.logger.debug(_("Could not find '%{vendored_bin_path}' in PDK package, trying '%{fallback}' from the system PATH instead") % { fallback: fallback, vendored_bin_path: vendored_bin_path }) fallback end end |