@nomad-e/bluma-cli 0.0.19 → 0.0.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.
- package/dist/main.js +33 -4
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2469,15 +2469,44 @@ import updateNotifier from "update-notifier";
|
|
|
2469
2469
|
import { readPackageUp } from "read-package-up";
|
|
2470
2470
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
2471
2471
|
import path9 from "path";
|
|
2472
|
+
import fs8 from "fs";
|
|
2473
|
+
function findPackageJsonNearest(startDir) {
|
|
2474
|
+
let dir = startDir;
|
|
2475
|
+
for (let i = 0; i < 6; i++) {
|
|
2476
|
+
const candidate = path9.join(dir, "package.json");
|
|
2477
|
+
if (fs8.existsSync(candidate)) {
|
|
2478
|
+
try {
|
|
2479
|
+
const raw = fs8.readFileSync(candidate, "utf8");
|
|
2480
|
+
const parsed = JSON.parse(raw);
|
|
2481
|
+
if (parsed?.name && parsed?.version) return parsed;
|
|
2482
|
+
} catch {
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
const parent = path9.dirname(dir);
|
|
2486
|
+
if (parent === dir) break;
|
|
2487
|
+
dir = parent;
|
|
2488
|
+
}
|
|
2489
|
+
return null;
|
|
2490
|
+
}
|
|
2472
2491
|
async function checkForUpdates() {
|
|
2473
2492
|
try {
|
|
2474
2493
|
if (process.env.BLUMA_FORCE_UPDATE_MSG) {
|
|
2475
2494
|
return String(process.env.BLUMA_FORCE_UPDATE_MSG);
|
|
2476
2495
|
}
|
|
2477
|
-
const
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2496
|
+
const binPath = process.argv?.[1];
|
|
2497
|
+
let pkg;
|
|
2498
|
+
if (binPath && fs8.existsSync(binPath)) {
|
|
2499
|
+
const candidatePkg = findPackageJsonNearest(path9.dirname(binPath));
|
|
2500
|
+
if (candidatePkg?.name && candidatePkg?.version) {
|
|
2501
|
+
pkg = candidatePkg;
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
if (!pkg) {
|
|
2505
|
+
const __filename = fileURLToPath3(import.meta.url);
|
|
2506
|
+
const __dirname = path9.dirname(__filename);
|
|
2507
|
+
const result = await readPackageUp({ cwd: __dirname });
|
|
2508
|
+
pkg = result?.packageJson;
|
|
2509
|
+
}
|
|
2481
2510
|
if (!pkg?.name || !pkg?.version) return null;
|
|
2482
2511
|
const isCI = Boolean(process.env.CI);
|
|
2483
2512
|
const isNoCache = process.env.BLUMA_UPDATE_NO_CACHE === "1";
|