Skip to content

Commit

Permalink
Optimized composer dependency handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-kuendig committed Mar 3, 2017
1 parent 0b95534 commit 55d606d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Util/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct()
*/
protected function findComposer()
{
if (file_exists(getcwd() . '/composer.phar')) {
if (file_exists(getcwd() . DS . 'composer.phar')) {
return '"' . PHP_BINARY . '" composer.phar';
}

Expand Down Expand Up @@ -64,6 +64,12 @@ public function install()
*/
public function addDependency($package)
{
// If the package is already installed don't add it again
$slashed = str_replace('/', '\/', $package);
if(preg_grep('/' . $slashed . '/', file(getcwd() . DS . 'composer.json'))) {
return true;
}

$package = escapeshellarg($package);

(new Process($this->composer . ' require ' . $package . ' --no-interaction'))
Expand Down

0 comments on commit 55d606d

Please sign in to comment.