Skip to content

Commit

Permalink
Add webmozart path util (#169)
Browse files Browse the repository at this point in the history
* [console] Fix package.

* [console] Add webmozart/path-util dependency.
  • Loading branch information
jmolivas committed Jun 20, 2017
1 parent 18f5564 commit 0b731ba
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 20 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"symfony/yaml": ">=2.7 <3.0",
"symfony/event-dispatcher": ">=2.7 <3.0",
"twig/twig": "^1.23.1",
"webflo/drupal-finder": "^0.3.0"
"webflo/drupal-finder": "^0.3.0",
"webmozart/path-util": "^2.3"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
98 changes: 97 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 5 additions & 18 deletions src/Utils/ConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Symfony\Component\Finder\Finder;
use Dflydev\DotAccessConfiguration\YamlFileConfigurationBuilder;
use Dflydev\DotAccessConfiguration\ConfigurationInterface;
use Webmozart\PathUtil\Path;

/**
* Class ConfigurationManager.
Expand Down Expand Up @@ -44,7 +45,7 @@ class ConfigurationManager
*/
public function loadConfiguration($applicationDirectory)
{
$homeConfig = $this->getHomeDirectory() . '/.console/';
$homeConfig = Path::getHomeDirectory() . '/.console/';
if (!is_dir($homeConfig)) {
mkdir($homeConfig, 0777);
}
Expand All @@ -57,7 +58,7 @@ public function loadConfiguration($applicationDirectory)
$configurationDirectories[] = $applicationDirectory.DRUPAL_CONSOLE_CORE;
$configurationDirectories[] = $applicationDirectory.DRUPAL_CONSOLE;
$configurationDirectories[] = '/etc/console/';
$configurationDirectories[] = $this->getHomeDirectory() . '/.console/';
$configurationDirectories[] = Path::getHomeDirectory() . '/.console/';
$configurationDirectories[] = $applicationDirectory .'/console/';
if ($root) {
$configurationDirectories[] = $root . '/console/';
Expand Down Expand Up @@ -148,20 +149,6 @@ public function readTarget($target)
);
}

/**
* Return the user home directory.
*
* @return string
*/
public function getHomeDirectory()
{
if (function_exists('posix_getuid')) {
return posix_getpwuid(posix_getuid())['dir'];
}

return realpath(rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\'));
}

/**
* @return string
*/
Expand Down Expand Up @@ -238,7 +225,7 @@ public function readDrushEquivalents($commandName)
*/
public function getConsoleDirectory()
{
return sprintf('%s/.console/', $this->getHomeDirectory());
return sprintf('%s/.console/', Path::getHomeDirectory());
}

/**
Expand Down Expand Up @@ -286,7 +273,7 @@ public function appendCommandAliases()

public function loadExtendConfiguration()
{
$directory = $this->getHomeDirectory() . '/.console/extend/';
$directory = Path::getHomeDirectory() . '/.console/extend/';
if (!is_dir($directory)) {
return null;
}
Expand Down

0 comments on commit 0b731ba

Please sign in to comment.