From: Dan Brown Date: Mon, 22 May 2023 07:30:44 +0000 (+0100) Subject: Fixed script-relative app locator when running as phar X-Git-Url: http://source.bookstackapp.com/system-cli/commitdiff_plain/88530332093fee51148b04c2f16a1b8f638b1211 Fixed script-relative app locator when running as phar Was previously doubling up on the dirname usage leading the locator to look at the parent dir when running as a phar, likely due to the CLI being previously nested in an app dir. Fixes #9 --- diff --git a/src/Services/AppLocator.php b/src/Services/AppLocator.php index 828bb22..155b8bb 100644 --- a/src/Services/AppLocator.php +++ b/src/Services/AppLocator.php @@ -13,6 +13,8 @@ class AppLocator static::getCliDirectory(), ]; + var_dump($directoriesToSearch); + foreach ($directoriesToSearch as $directory) { if ($directory && static::isProbablyAppDirectory($directory)) { return $directory; @@ -36,8 +38,9 @@ class AppLocator protected static function getCliDirectory(): string { $scriptDir = dirname(__DIR__); + if (str_starts_with($scriptDir, 'phar://')) { - $scriptDir = dirname(Phar::running(false)); + return dirname(Phar::running(false)); } return dirname($scriptDir);