Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing repo.root detection, removing duplicative methods. #1660

Merged
merged 1 commit into from
Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/blt-robo-run.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
$input = new ArgvInput($_SERVER['argv']);
$output = new ConsoleOutput();

$config = new DefaultConfig();
$config = new DefaultConfig($repo_root);
$loader = new YamlConfigLoader();
$processor = new YamlConfigProcessor();
$processor->add($config->export());
Expand Down
33 changes: 6 additions & 27 deletions src/Robo/Config/DefaultConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Acquia\Blt\Robo\Config;

use Acquia\Blt\Robo\Exceptions\BltException;
use Robo\Config\YamlConfigLoader;
use Symfony\Component\Finder\Finder;

Expand All @@ -11,42 +12,20 @@
class DefaultConfig extends BltConfig {

/**
* Constructor.
* DefaultConfig constructor.
*
* @param string $repo_root
* The repository root of the project that depends on BLT.
*/
public function __construct() {
public function __construct($repo_root) {
parent::__construct();

$repo_root = $this->getRepoRoot();
$this->set('repo.root', $repo_root);
$this->set('docroot', $repo_root . '/docroot');
$this->set('blt.root', $this->getBltRoot());
$this->set('composer.bin', $repo_root . '/vendor/bin');
}

/**
* Gets the repository root.
*
* @return string
* The filepath for the repository root.
*
* @throws \Exception
*/
protected function getRepoRoot() {
$possible_repo_roots = [
$_SERVER['PWD'],
realpath($_SERVER['PWD'] . '/..'),
getcwd(),
];
foreach ($possible_repo_roots as $possible_repo_root) {
if (file_exists("$possible_repo_root/vendor/acquia/blt")
||file_exists("$possible_repo_root/blt/project.yml")) {
return $possible_repo_root;
}
}

throw new BltException('Could not find repository root directory!');
}

/**
* Gets the BLT root directory. E.g., /vendor/acquia/blt.
*
Expand Down