Skip to content

Commit 2fdc80e

Browse files
committed
Changed how root directory is resolved
1 parent 0118b9c commit 2fdc80e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/Core/Options.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace Okapi\CodeTransformer\Core;
44

5+
use Composer\Autoload\ClassLoader;
56
use Okapi\CodeTransformer\CodeTransformerKernel;
67
use Okapi\Path\Path;
8+
use ReflectionClass;
79

810
/**
911
* # Options
@@ -68,13 +70,9 @@ public function setOptions(
6870
?int $cacheFileMode,
6971
?bool $debug,
7072
): void {
71-
$rootDir = getcwd();
72-
73-
if ($rootDir === false) {
74-
// @codeCoverageIgnoreStart
75-
$rootDir = Path::resolve(Path::join(__DIR__, '../../../../..'));
76-
// @codeCoverageIgnoreEnd
77-
}
73+
$composerRef = new ReflectionClass(ClassLoader::class);
74+
$composerDir = $composerRef->getFileName();
75+
$rootDir = Path::resolve(Path::join($composerDir, '../../..'));
7876

7977
$this->appDir = $rootDir;
8078
$this->cacheDir = $cacheDir ?? Path::join($rootDir, $this->defaultCacheDir);

0 commit comments

Comments
 (0)