Skip to content

Commit

Permalink
🔨 Ensures absolute paths during detection fase
Browse files Browse the repository at this point in the history
Ref #63
  • Loading branch information
frenck committed Oct 26, 2018
1 parent 1efacc8 commit ab1a545
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Plugin.php
Expand Up @@ -72,6 +72,11 @@ class Plugin implements PluginInterface, EventSubscriberInterface
*/
private $filesystem;

/**
* @var string
*/
private $cwd;

/**
* Triggers the plugin's main functionality.
*
Expand Down Expand Up @@ -127,6 +132,7 @@ private function init()
$this->installedPaths = array();
$this->processExecutor = new ProcessExecutor($this->io);
$this->filesystem = new Filesystem($this->processExecutor);
$this->cwd = getcwd();
}

/**
Expand Down Expand Up @@ -285,10 +291,16 @@ private function updateInstalledPaths()
{
$changes = false;

$searchPaths = array(getcwd());
$searchPaths = array($this->cwd);
$codingStandardPackages = $this->getPHPCodingStandardPackages();
foreach ($codingStandardPackages as $package) {
$searchPaths[] = $this->composer->getInstallationManager()->getInstallPath($package);
$installPath = $this->composer->getInstallationManager()->getInstallPath($package);
if ($this->filesystem->isAbsolutePath($installPath) === false) {
$installPath = $this->filesystem->normalizePath(
$this->cwd . DIRECTORY_SEPARATOR . $installPath
);
}
$searchPaths[] = $installPath;
}

$finder = new Finder();
Expand Down Expand Up @@ -408,7 +420,7 @@ private function isPHPCodeSnifferInstalled($versionConstraint = null)
*/
private function isRunningGlobally()
{
return ($this->composer->getConfig()->get('home') === getcwd());
return ($this->composer->getConfig()->get('home') === $this->cwd);
}

/**
Expand Down

0 comments on commit ab1a545

Please sign in to comment.