@vizamodo/viza-cli 1.2.18 → 1.2.21

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.
@@ -20,34 +20,29 @@ export function getCliVersion() {
20
20
  }
21
21
  try {
22
22
  const here = fileURLToPath(import.meta.url);
23
- const dir = resolve(here, "..");
24
- const candidates = [
25
- resolve(dir, "../../package.json"),
26
- resolve(dir, "../../../package.json"),
27
- resolve(dir, "../../../../package.json"),
28
- ];
29
- let raw;
30
- let usedPath;
31
- for (const p of candidates) {
23
+ let dir = dirname(here);
24
+ // Walk up to find the package.json that belongs to this CLI package.
25
+ for (let i = 0; i < 8; i++) {
26
+ const pkgPath = resolve(dir, "package.json");
32
27
  try {
33
- raw = readFileSync(p, "utf8");
34
- usedPath = p;
35
- break;
28
+ const raw = readFileSync(pkgPath, "utf8");
29
+ const json = JSON.parse(raw);
30
+ if (json?.name === "@vizamodo/viza-cli" && typeof json.version === "string" && json.version.trim()) {
31
+ _cached = json.version.trim();
32
+ return _cached;
33
+ }
36
34
  }
37
35
  catch {
38
- // try next
36
+ // ignore and keep walking up
39
37
  }
40
- }
41
- if (!raw || !usedPath) {
42
- throw new Error(`package.json not found (tried: ${candidates.join(", ")})`);
43
- }
44
- const json = JSON.parse(raw);
45
- if (json.version && String(json.version).trim()) {
46
- _cached = String(json.version).trim();
47
- return _cached;
38
+ const parent = resolve(dir, "..");
39
+ if (parent === dir)
40
+ break;
41
+ dir = parent;
48
42
  }
49
43
  }
50
- catch (err) {
44
+ catch {
45
+ // ignore
51
46
  }
52
47
  _cached = "dev";
53
48
  return _cached;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizamodo/viza-cli",
3
- "version": "1.2.18",
3
+ "version": "1.2.21",
4
4
  "type": "module",
5
5
  "description": "Viza unified command line interface",
6
6
  "bin": {