Skip to content

Commit

Permalink
Merge branch 'Hermsi1337-#120-configurable-home'
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenrombauts committed Jun 3, 2020
2 parents 165354f + d0407bb commit 23fde99
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/Joomlatools/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,14 @@ public function run(Input\InputInterface $input = null, Output\OutputInterface $
*/
public function getConsoleHome()
{
return rtrim(getenv('HOME'), '/') . '/.joomlatools/console';
$home = getenv('HOME');
$customHome = getenv('JOOMLATOOLS_CONSOLE_HOME');

if (!empty($customHome)) {
$home = $customHome;
}

return rtrim($home, '/') . '/.joomlatools/console';
}

/**
Expand Down Expand Up @@ -215,17 +222,19 @@ public function getPlugins()
*/
protected function _setup()
{
if (!file_exists($this->getConsoleHome()))
$home = $this->getConsoleHome();

if (!file_exists($home))
{
$result = @mkdir($this->getConsoleHome(), 0775, true);
$result = @mkdir($home, 0775, true);

if (!$result) {
$this->_output->writeln(sprintf('<error>Unable to write to home directory: %s. Please check write permissions.</error>', getenv('HOME')));
$this->_output->writeln(sprintf('<error>Unable to create home directory: %s. Please check write permissions.</error>', $home));
}
}

// Handle legacy plugin directory
if (is_writable($this->getConsoleHome()) && !file_exists($this->getPluginPath()))
if (is_writable($home) && !file_exists($this->getPluginPath()))
{
$old = realpath(dirname(__FILE__) . '/../../../plugins/');

Expand Down

0 comments on commit 23fde99

Please sign in to comment.