/** * @throws DependencyMissingException * * @return string|false */ public function getVersion() { static $version; if (!$version) { if (!$this->shellHelper->commandExists('git')) { throw new DependencyMissingException('Git must be installed'); } $version = false; $string = $this->execute(['--version'], false); if ($string && preg_match('/(^| )([0-9]+[^ ]*)/', $string, $matches)) { $version = $matches[2]; } } return $version; }
/** * @throws DependencyMissingException */ public function ensureInstalled() { static $installed; if (empty($installed) && $this->getDrushExecutable() === 'drush' && !$this->shellHelper->commandExists('drush')) { throw new DependencyMissingException('Drush is not installed'); } $installed = true; }
/** * @return string */ protected function getTarExecutable() { $candidates = ['tar', 'tar.exe', 'bsdtar.exe']; foreach ($candidates as $command) { if ($this->shellHelper->commandExists($command)) { return $command; } } throw new \RuntimeException("Tar command not found"); }
/** * Ensure that the Git CLI is installed. * * @throws DependencyMissingException */ public function ensureInstalled() { if (!$this->shellHelper->commandExists('git')) { throw new DependencyMissingException('Git must be installed'); } }