]> BookStack Code Mirror - system-cli/commitdiff
Fixed script-relative app locator when running as phar
authorDan Brown <redacted>
Mon, 22 May 2023 07:30:44 +0000 (08:30 +0100)
committerDan Brown <redacted>
Mon, 22 May 2023 07:31:50 +0000 (08:31 +0100)
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

src/Services/AppLocator.php

index 828bb221e538d70be3936ddb7cdb609930fc1ea6..155b8bb61d7a6aadc1886af34208af9b849de155 100644 (file)
@@ -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);