* @returns {string} path to cache dir
()
| 549 | * @returns {string} path to cache dir |
| 550 | */ |
| 551 | static findCacheDir() { |
| 552 | const cwd = process.cwd(); |
| 553 | |
| 554 | /** |
| 555 | * @type {string | undefined} |
| 556 | */ |
| 557 | let dir = cwd; |
| 558 | |
| 559 | for (;;) { |
| 560 | try { |
| 561 | if (fs.statSync(path.join(dir, "package.json")).isFile()) break; |
| 562 | // eslint-disable-next-line no-empty |
| 563 | } catch {} |
| 564 | |
| 565 | const parent = path.dirname(dir); |
| 566 | |
| 567 | if (dir === parent) { |
| 568 | dir = undefined; |
| 569 | break; |
| 570 | } |
| 571 | |
| 572 | dir = parent; |
| 573 | } |
| 574 | |
| 575 | if (!dir) { |
| 576 | return path.resolve(cwd, `.cache/${pluginName}`); |
| 577 | } else if (process.versions.pnp === "1") { |
| 578 | return path.resolve(dir, `.pnp/.cache/${pluginName}`); |
| 579 | } else if (process.versions.pnp === "3") { |
| 580 | return path.resolve(dir, `.yarn/.cache/${pluginName}`); |
| 581 | } |
| 582 | |
| 583 | return path.resolve(dir, `node_modules/.cache/${pluginName}`); |
| 584 | } |
| 585 | |
| 586 | /** |
| 587 | * @private |
no outgoing calls
no test coverage detected