@vizamodo/viza-cli 1.2.17 → 1.2.20
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/src/core/version.js +17 -22
- package/package.json +1 -1
package/dist/src/core/version.js
CHANGED
|
@@ -20,34 +20,29 @@ export function getCliVersion() {
|
|
|
20
20
|
}
|
|
21
21
|
try {
|
|
22
22
|
const here = fileURLToPath(import.meta.url);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
resolve(dir, "
|
|
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(
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
//
|
|
36
|
+
// ignore and keep walking up
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
44
|
+
catch {
|
|
45
|
+
// ignore
|
|
51
46
|
}
|
|
52
47
|
_cached = "dev";
|
|
53
48
|
return _cached;
|