From f980c8db515e74f0c6026e84572a9b412bbdb94f Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Mon, 5 Mar 2018 09:14:28 -0800 Subject: [PATCH] Add daemonutils to locate autoloader --- Core/bin/google-cloud-batch | 17 ++++------- Core/src/Daemon/DaemonUtils.php | 46 ++++++++++++++++++++++++++++++ Debugger/bin/google-cloud-debugger | 17 ++++------- 3 files changed, 58 insertions(+), 22 deletions(-) create mode 100644 Core/src/Daemon/DaemonUtils.php diff --git a/Core/bin/google-cloud-batch b/Core/bin/google-cloud-batch index b0114986908b..40ec606a07eb 100755 --- a/Core/bin/google-cloud-batch +++ b/Core/bin/google-cloud-batch @@ -18,20 +18,15 @@ namespace Google\Cloud\Core\Batch; -// Load the autoloader -if (file_exists(__DIR__ . '/../vendor/autoload.php')) { - // Called from local git clone. - require_once __DIR__ . '/../vendor/autoload.php'; -} elseif (file_exists(__DIR__ . '/../../../autoload.php')) { - // Called from google/cloud-core installation. - require_once __DIR__ . '/../../../autoload.php'; -} elseif (file_exists(__DIR__ . '/../../../../autoload.php')) { - // Called from google/cloud installation. - require_once __DIR__ . '/../../../../autoload.php'; -} else { +use Google\Cloud\Core\Daemon\DaemonUtils; + +$autoloader = DaemonUtils::locateAutoloader(__DIR__ . '/..'); +if (is_null($autoloader)) { die('No autoloader found'); } +require_once $autoloader; + function showUsageAndDie() { die("usage: " . __FILE__ . " [daemon|retry] {id}"); diff --git a/Core/src/Daemon/DaemonUtils.php b/Core/src/Daemon/DaemonUtils.php new file mode 100644 index 000000000000..dbfdd80c6db1 --- /dev/null +++ b/Core/src/Daemon/DaemonUtils.php @@ -0,0 +1,46 @@ +