From 55d606d797acf0db5ab456c02efad1bf3b33cdda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20K=C3=BCndig?= Date: Fri, 3 Mar 2017 17:50:35 +0100 Subject: [PATCH] Optimized composer dependency handling --- src/Util/Composer.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Util/Composer.php b/src/Util/Composer.php index 997b6a2..cda77fc 100644 --- a/src/Util/Composer.php +++ b/src/Util/Composer.php @@ -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'; } @@ -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'))