From b4f96b5020a9851659739ca7ce4e56dc8db1ee4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Draho=C5=A1?= Date: Sat, 7 Jan 2017 10:36:33 +0100 Subject: [PATCH 1/2] bin-dir - fail fast when bin dir is in unknown location --- phpqa | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpqa b/phpqa index cce680c4..6a5f9a91 100755 --- a/phpqa +++ b/phpqa @@ -11,6 +11,10 @@ if (file_exists(__DIR__ . '/vendor/autoload.php')) { require_once __DIR__ . '/../../autoload.php'; } +if (!defined('COMPOSER_BINARY_DIR') || !is_file(COMPOSER_BINARY_DIR . 'phploc')) { + die("Composer binary directory was not found\n"); +} + /** * RoboFile is in phpqa repository, but analysis is runned in cwd. * Robo\Runner:loadRoboFile calls chdir when option --load-from=__DIR__ From b305219d9802f7bd5bb393d91145c3097f194241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Draho=C5=A1?= Date: Sat, 7 Jan 2017 10:40:40 +0100 Subject: [PATCH 2/2] bin-dir - detect bin dir in common paths or use env variable --- phpqa | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/phpqa b/phpqa index 6a5f9a91..48be46ea 100755 --- a/phpqa +++ b/phpqa @@ -7,12 +7,24 @@ if (file_exists(__DIR__ . '/vendor/autoload.php')) { define('COMPOSER_BINARY_DIR', __DIR__ . "/vendor/bin/"); require_once __DIR__ . '/vendor/autoload.php'; } elseif (file_exists(__DIR__ . '/../../autoload.php')) { - define('COMPOSER_BINARY_DIR', __DIR__ . "/../../bin/"); + $projectRoot = __DIR__ . '/../../..'; + $binPaths = [ + "{$projectRoot}/vendor/bin", + "{$projectRoot}/bin", + $projectRoot, + "{$projectRoot}/" . getenv('COMPOSER_BIN_DIR'), + ]; + foreach ($binPaths as $bin) { + if (is_file("{$bin}/phploc")) { + define('COMPOSER_BINARY_DIR', "{$bin}/"); + break; + } + } require_once __DIR__ . '/../../autoload.php'; } if (!defined('COMPOSER_BINARY_DIR') || !is_file(COMPOSER_BINARY_DIR . 'phploc')) { - die("Composer binary directory was not found\n"); + die("Composer binary directory was not found (define path in environment variable 'COMPOSER_BIN_DIR')\n"); } /**