locus-product-planning 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -12441,32 +12441,51 @@ import { homedir } from "os";
12441
12441
  import { readFileSync, existsSync, readdirSync } from "fs";
12442
12442
  import { join, basename, dirname, resolve } from "path";
12443
12443
  import { fileURLToPath } from "url";
12444
+ var _cachedDirname = null;
12444
12445
  function getCurrentDirname() {
12446
+ if (_cachedDirname) return _cachedDirname;
12445
12447
  try {
12446
12448
  const meta = import.meta;
12447
12449
  if (meta?.url && typeof meta.url === "string" && meta.url.startsWith("file:")) {
12448
12450
  const result = dirname(fileURLToPath(meta.url));
12449
12451
  if (typeof result === "string" && result.length > 0) {
12452
+ _cachedDirname = result;
12450
12453
  return result;
12451
12454
  }
12452
12455
  }
12453
12456
  } catch {
12454
12457
  }
12458
+ try {
12459
+ const globalDirname = globalThis.__dirname;
12460
+ if (typeof globalDirname === "string" && globalDirname.length > 0) {
12461
+ _cachedDirname = globalDirname;
12462
+ return globalDirname;
12463
+ }
12464
+ } catch {
12465
+ }
12455
12466
  try {
12456
12467
  const packageJsonPath = __require.resolve("locus-product-planning/package.json");
12457
12468
  if (typeof packageJsonPath === "string") {
12458
- return join(dirname(packageJsonPath), "dist");
12469
+ const result = join(dirname(packageJsonPath), "dist");
12470
+ _cachedDirname = result;
12471
+ return result;
12459
12472
  }
12460
12473
  } catch {
12461
12474
  }
12462
- const cacheLocations = [
12463
- join(process.env.HOME || "", ".cache", "opencode", "node_modules", "locus-product-planning"),
12464
- join(process.env.HOME || "", ".config", "opencode", "node_modules", "locus-product-planning")
12465
- ];
12466
- for (const loc of cacheLocations) {
12467
- const distPath = join(loc, "dist");
12468
- if (existsSync(distPath)) {
12469
- return distPath;
12475
+ const homeDir = process.env.USERPROFILE || process.env.HOME || "";
12476
+ if (homeDir) {
12477
+ const cacheLocations = [
12478
+ join(homeDir, ".cache", "opencode", "node_modules", "locus-product-planning", "dist"),
12479
+ join(homeDir, ".config", "opencode", "node_modules", "locus-product-planning", "dist")
12480
+ ];
12481
+ for (const loc of cacheLocations) {
12482
+ try {
12483
+ if (existsSync(loc)) {
12484
+ _cachedDirname = loc;
12485
+ return loc;
12486
+ }
12487
+ } catch {
12488
+ }
12470
12489
  }
12471
12490
  }
12472
12491
  const cwd = process.cwd();
@@ -12475,12 +12494,16 @@ function getCurrentDirname() {
12475
12494
  if (existsSync(pkgPath)) {
12476
12495
  const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
12477
12496
  if (pkg.name === "locus-product-planning") {
12478
- return resolve(cwd, "dist");
12497
+ const result = resolve(cwd, "dist");
12498
+ _cachedDirname = result;
12499
+ return result;
12479
12500
  }
12480
12501
  }
12481
12502
  } catch {
12482
12503
  }
12483
- return resolve(cwd, "dist");
12504
+ const fallback = resolve(cwd, "dist");
12505
+ _cachedDirname = fallback;
12506
+ return fallback;
12484
12507
  }
12485
12508
  var currentDirname = getCurrentDirname();
12486
12509
  function getPackageRoot() {