locus-product-planning 1.2.3 → 1.2.4

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
@@ -12442,13 +12442,22 @@ import { readFileSync, existsSync, readdirSync } from "fs";
12442
12442
  import { join, basename, dirname, resolve } from "path";
12443
12443
  import { fileURLToPath } from "url";
12444
12444
  var _cachedDirname = null;
12445
+ function safeString(value) {
12446
+ if (typeof value === "string" && value.length > 0) {
12447
+ return value;
12448
+ }
12449
+ return null;
12450
+ }
12445
12451
  function getCurrentDirname() {
12446
- if (_cachedDirname) return _cachedDirname;
12452
+ if (typeof _cachedDirname === "string" && _cachedDirname.length > 0) {
12453
+ return _cachedDirname;
12454
+ }
12447
12455
  try {
12448
12456
  const meta = import.meta;
12449
- if (meta?.url && typeof meta.url === "string" && meta.url.startsWith("file:")) {
12450
- const result = dirname(fileURLToPath(meta.url));
12451
- if (typeof result === "string" && result.length > 0) {
12457
+ const url2 = safeString(meta?.url);
12458
+ if (url2 && url2.startsWith("file:")) {
12459
+ const result = safeString(dirname(fileURLToPath(url2)));
12460
+ if (result) {
12452
12461
  _cachedDirname = result;
12453
12462
  return result;
12454
12463
  }
@@ -12456,23 +12465,25 @@ function getCurrentDirname() {
12456
12465
  } catch {
12457
12466
  }
12458
12467
  try {
12459
- const globalDirname = globalThis.__dirname;
12460
- if (typeof globalDirname === "string" && globalDirname.length > 0) {
12468
+ const globalDirname = safeString(globalThis.__dirname);
12469
+ if (globalDirname) {
12461
12470
  _cachedDirname = globalDirname;
12462
12471
  return globalDirname;
12463
12472
  }
12464
12473
  } catch {
12465
12474
  }
12466
12475
  try {
12467
- const packageJsonPath = __require.resolve("locus-product-planning/package.json");
12468
- if (typeof packageJsonPath === "string") {
12469
- const result = join(dirname(packageJsonPath), "dist");
12470
- _cachedDirname = result;
12471
- return result;
12476
+ const packageJsonPath = safeString(__require.resolve("locus-product-planning/package.json"));
12477
+ if (packageJsonPath) {
12478
+ const result = safeString(join(dirname(packageJsonPath), "dist"));
12479
+ if (result) {
12480
+ _cachedDirname = result;
12481
+ return result;
12482
+ }
12472
12483
  }
12473
12484
  } catch {
12474
12485
  }
12475
- const homeDir = process.env.USERPROFILE || process.env.HOME || "";
12486
+ const homeDir = safeString(process.env.USERPROFILE) || safeString(process.env.HOME);
12476
12487
  if (homeDir) {
12477
12488
  const cacheLocations = [
12478
12489
  join(homeDir, ".cache", "opencode", "node_modules", "locus-product-planning", "dist"),
@@ -12481,29 +12492,41 @@ function getCurrentDirname() {
12481
12492
  for (const loc of cacheLocations) {
12482
12493
  try {
12483
12494
  if (existsSync(loc)) {
12484
- _cachedDirname = loc;
12485
- return loc;
12495
+ const result = safeString(loc);
12496
+ if (result) {
12497
+ _cachedDirname = result;
12498
+ return result;
12499
+ }
12486
12500
  }
12487
12501
  } catch {
12488
12502
  }
12489
12503
  }
12490
12504
  }
12491
- const cwd = process.cwd();
12492
- try {
12493
- const pkgPath = resolve(cwd, "package.json");
12494
- if (existsSync(pkgPath)) {
12495
- const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
12496
- if (pkg.name === "locus-product-planning") {
12497
- const result = resolve(cwd, "dist");
12498
- _cachedDirname = result;
12499
- return result;
12505
+ const cwd = safeString(process.cwd());
12506
+ if (cwd) {
12507
+ try {
12508
+ const pkgPath = resolve(cwd, "package.json");
12509
+ if (existsSync(pkgPath)) {
12510
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
12511
+ if (pkg.name === "locus-product-planning") {
12512
+ const result = safeString(resolve(cwd, "dist"));
12513
+ if (result) {
12514
+ _cachedDirname = result;
12515
+ return result;
12516
+ }
12517
+ }
12500
12518
  }
12519
+ } catch {
12520
+ }
12521
+ const fallback = safeString(resolve(cwd, "dist"));
12522
+ if (fallback) {
12523
+ _cachedDirname = fallback;
12524
+ return fallback;
12501
12525
  }
12502
- } catch {
12503
12526
  }
12504
- const fallback = resolve(cwd, "dist");
12505
- _cachedDirname = fallback;
12506
- return fallback;
12527
+ const absoluteFallback = "/tmp/locus-product-planning/dist";
12528
+ _cachedDirname = absoluteFallback;
12529
+ return absoluteFallback;
12507
12530
  }
12508
12531
  var currentDirname = getCurrentDirname();
12509
12532
  function getPackageRoot() {