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.cjs CHANGED
@@ -12478,13 +12478,22 @@ var import_path = require("path");
12478
12478
  var import_url = require("url");
12479
12479
  var import_meta = {};
12480
12480
  var _cachedDirname = null;
12481
+ function safeString(value) {
12482
+ if (typeof value === "string" && value.length > 0) {
12483
+ return value;
12484
+ }
12485
+ return null;
12486
+ }
12481
12487
  function getCurrentDirname() {
12482
- if (_cachedDirname) return _cachedDirname;
12488
+ if (typeof _cachedDirname === "string" && _cachedDirname.length > 0) {
12489
+ return _cachedDirname;
12490
+ }
12483
12491
  try {
12484
12492
  const meta = import_meta;
12485
- if (meta?.url && typeof meta.url === "string" && meta.url.startsWith("file:")) {
12486
- const result = (0, import_path.dirname)((0, import_url.fileURLToPath)(meta.url));
12487
- if (typeof result === "string" && result.length > 0) {
12493
+ const url2 = safeString(meta?.url);
12494
+ if (url2 && url2.startsWith("file:")) {
12495
+ const result = safeString((0, import_path.dirname)((0, import_url.fileURLToPath)(url2)));
12496
+ if (result) {
12488
12497
  _cachedDirname = result;
12489
12498
  return result;
12490
12499
  }
@@ -12492,23 +12501,25 @@ function getCurrentDirname() {
12492
12501
  } catch {
12493
12502
  }
12494
12503
  try {
12495
- const globalDirname = globalThis.__dirname;
12496
- if (typeof globalDirname === "string" && globalDirname.length > 0) {
12504
+ const globalDirname = safeString(globalThis.__dirname);
12505
+ if (globalDirname) {
12497
12506
  _cachedDirname = globalDirname;
12498
12507
  return globalDirname;
12499
12508
  }
12500
12509
  } catch {
12501
12510
  }
12502
12511
  try {
12503
- const packageJsonPath = require.resolve("locus-product-planning/package.json");
12504
- if (typeof packageJsonPath === "string") {
12505
- const result = (0, import_path.join)((0, import_path.dirname)(packageJsonPath), "dist");
12506
- _cachedDirname = result;
12507
- return result;
12512
+ const packageJsonPath = safeString(require.resolve("locus-product-planning/package.json"));
12513
+ if (packageJsonPath) {
12514
+ const result = safeString((0, import_path.join)((0, import_path.dirname)(packageJsonPath), "dist"));
12515
+ if (result) {
12516
+ _cachedDirname = result;
12517
+ return result;
12518
+ }
12508
12519
  }
12509
12520
  } catch {
12510
12521
  }
12511
- const homeDir = process.env.USERPROFILE || process.env.HOME || "";
12522
+ const homeDir = safeString(process.env.USERPROFILE) || safeString(process.env.HOME);
12512
12523
  if (homeDir) {
12513
12524
  const cacheLocations = [
12514
12525
  (0, import_path.join)(homeDir, ".cache", "opencode", "node_modules", "locus-product-planning", "dist"),
@@ -12517,29 +12528,41 @@ function getCurrentDirname() {
12517
12528
  for (const loc of cacheLocations) {
12518
12529
  try {
12519
12530
  if ((0, import_fs.existsSync)(loc)) {
12520
- _cachedDirname = loc;
12521
- return loc;
12531
+ const result = safeString(loc);
12532
+ if (result) {
12533
+ _cachedDirname = result;
12534
+ return result;
12535
+ }
12522
12536
  }
12523
12537
  } catch {
12524
12538
  }
12525
12539
  }
12526
12540
  }
12527
- const cwd = process.cwd();
12528
- try {
12529
- const pkgPath = (0, import_path.resolve)(cwd, "package.json");
12530
- if ((0, import_fs.existsSync)(pkgPath)) {
12531
- const pkg = JSON.parse((0, import_fs.readFileSync)(pkgPath, "utf-8"));
12532
- if (pkg.name === "locus-product-planning") {
12533
- const result = (0, import_path.resolve)(cwd, "dist");
12534
- _cachedDirname = result;
12535
- return result;
12541
+ const cwd = safeString(process.cwd());
12542
+ if (cwd) {
12543
+ try {
12544
+ const pkgPath = (0, import_path.resolve)(cwd, "package.json");
12545
+ if ((0, import_fs.existsSync)(pkgPath)) {
12546
+ const pkg = JSON.parse((0, import_fs.readFileSync)(pkgPath, "utf-8"));
12547
+ if (pkg.name === "locus-product-planning") {
12548
+ const result = safeString((0, import_path.resolve)(cwd, "dist"));
12549
+ if (result) {
12550
+ _cachedDirname = result;
12551
+ return result;
12552
+ }
12553
+ }
12536
12554
  }
12555
+ } catch {
12556
+ }
12557
+ const fallback = safeString((0, import_path.resolve)(cwd, "dist"));
12558
+ if (fallback) {
12559
+ _cachedDirname = fallback;
12560
+ return fallback;
12537
12561
  }
12538
- } catch {
12539
12562
  }
12540
- const fallback = (0, import_path.resolve)(cwd, "dist");
12541
- _cachedDirname = fallback;
12542
- return fallback;
12563
+ const absoluteFallback = "/tmp/locus-product-planning/dist";
12564
+ _cachedDirname = absoluteFallback;
12565
+ return absoluteFallback;
12543
12566
  }
12544
12567
  var currentDirname = getCurrentDirname();
12545
12568
  function getPackageRoot() {