| 17 | } |
| 18 | |
| 19 | get rootDir() { |
| 20 | if (!this._rootDir) { |
| 21 | const fsRoot = resolve('/'); |
| 22 | let testDir = process.cwd(); |
| 23 | for (let i = 0; i < 20; i++) { |
| 24 | const pkgPath = join(testDir, 'package.json'); |
| 25 | if (existsSync(pkgPath)) { |
| 26 | this._rootDir = testDir; |
| 27 | break; |
| 28 | } |
| 29 | if (testDir === fsRoot) { |
| 30 | break; |
| 31 | } |
| 32 | testDir = dirname(testDir); |
| 33 | } |
| 34 | if (!this._rootDir) { |
| 35 | throw new Error(`Unable to find Qwik app package.json`); |
| 36 | } |
| 37 | } |
| 38 | return this._rootDir; |
| 39 | } |
| 40 | |
| 41 | set rootDir(rootDir) { |
| 42 | this._rootDir = rootDir; |