Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lander Vanderstraeten committed Feb 22, 2019
1 parent 7ecaa8b commit 9e84839
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ protected function initializeComposerHelper(): Helper\ComposerHelper
}

$composerFileLocation = getcwd().DIRECTORY_SEPARATOR.'composer.json';
ComposerFile::ensureProjectBinDirInSystemPath($composerFileLocation);
$composerFile = ComposerFile::createFrom($composerFileLocation);

return $this->composerHelper = new Helper\ComposerHelper($composerFile);
Expand Down
12 changes: 4 additions & 8 deletions src/Util/ComposerFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public static function createFrom(string $composerFileLocation): self
*
* @see https://github.com/composer/composer/blob/1.1/src/Composer/EventDispatcher/EventDispatcher.php#L147-L160
*/
private static function ensureProjectBinDirInSystemPath(string $binDir): bool
public static function ensureProjectBinDirInSystemPath(string $binDir)
{
$pathStr = 'PATH';
if (!isset($_SERVER[$pathStr]) && isset($_SERVER['Path'])) {
$pathStr = 'Path';
}

if (!is_dir($binDir)) {
return false;
return;
}

// add the bin dir to the PATH to make local binaries of deps usable in scripts
Expand All @@ -54,19 +54,15 @@ private static function ensureProjectBinDirInSystemPath(string $binDir): bool
$_SERVER[$pathStr] = $binDir.PATH_SEPARATOR.getenv($pathStr);
putenv($pathStr.'='.$_SERVER[$pathStr]);
}

return true;
}

public function getBinDir(): string
{
$binDir = $this->configuration['bin-dir'] ?? 'vendor/bin';

if (self::ensureProjectBinDirInSystemPath($binDir)) {
return $binDir;
}
self::ensureProjectBinDirInSystemPath($binDir);

throw new RuntimeException('Could not get bin dir location');
return $binDir;
}

/**
Expand Down

0 comments on commit 9e84839

Please sign in to comment.