From 7771d81c6b3ea5587ad30288c7faad6d96b2ec59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Thu, 28 Sep 2023 18:16:48 +0200 Subject: [PATCH] Use phar file path as fallback If no root dir could be detected, try to use the current directory of the phar file instead. --- src/N98/Magento/Application/MagentoDetector.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/N98/Magento/Application/MagentoDetector.php b/src/N98/Magento/Application/MagentoDetector.php index 4b924e9ce..30c48cb51 100644 --- a/src/N98/Magento/Application/MagentoDetector.php +++ b/src/N98/Magento/Application/MagentoDetector.php @@ -51,7 +51,15 @@ public function detect( /* @var $magentoHelper MagentoHelper */ $magentoHelper = $helperSet->get('magento'); - return new DetectionResult($magentoHelper, $folder, $subFolders); // @TODO must be refactored + $result = new DetectionResult($magentoHelper, $folder, $subFolders); + if ($result->isDetected()) { + return $result; + } + + // try to detect magento at the location of n98-magerun2.phar + $folder = $this->resolveRootDirOption(dirname($_SERVER['argv'][0])); + + return new DetectionResult($magentoHelper, $folder, $subFolders); } /**