MCPcopy
hub / github.com/webpack/webpack-dev-server / findCacheDir

Method findCacheDir

lib/Server.js:551–584  ·  view source on GitHub ↗

* @returns {string} path to cache dir

()

Source from the content-addressed store, hash-verified

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

Callers 3

normalizeOptionsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected