public getProjectRoot ( ) : string | false | ||
리턴 | string | false |
public function getProjectRoot()
{
// Backwards compatibility - if in an old-style project root, change
// directory to the repository.
if (is_dir('repository') && file_exists($this->config->get('local.project_config_legacy'))) {
$cwd = getcwd();
chdir('repository');
}
// The project root is a Git repository, which contains a project
// configuration file, and/or contains a Git remote with the appropriate
// domain.
$dir = $this->findTopDirectoryContaining('.git', function ($dir) {
$config = $this->getProjectConfig($dir);
return !empty($config);
});
if (isset($cwd)) {
chdir($cwd);
}
return $dir;
}
/** * @inheritdoc */ protected function initialize(InputInterface $input, OutputInterface $output) { // Validate we can run. if ($this->platformConfig === null) { $output->writeln('<error>Must run command within a Platform.sh project</error>'); exit(1); } $this->projectPath = LocalProject::getProjectRoot(); $this->projectName = Platform::projectName(); $this->stdOut = $output; $this->stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; $this->stdIn = $input; self::$interactive = $input->isInteractive(); }