Lines 1-58javascript
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.updateCommand = updateCommand;
4const child_process_1 = require("child_process");
5const banner_1 = require("../utils/banner");
HighChild Process
Package source references child process execution.
dist/commands/update.jsView on unpkg · L3 6const version_1 = require("../version");
7function getLatestVersion(pkg) {
8 const result = (0, child_process_1.spawnSync)("npm", ["view", pkg, "version"], { encoding: "utf-8" });
9 if (result.error || result.status !== 0)
10 throw new Error("Could not fetch latest version from npm registry");
11 return result.stdout.trim();
13function isGlobalInstall() {
15 const globalBin = (0, child_process_1.execSync)("npm root -g", { encoding: "utf-8" }).trim();
16 const selfBin = (0, child_process_1.execSync)("npm root", { encoding: "utf-8", cwd: __dirname }).trim();
17 return selfBin.startsWith(globalBin);
23async function updateCommand() {
24 const pkg = "@broxium/cli";
25 console.log(`\n\x1b[35m◆ Broxium Self-Update\x1b[0m\n`);
26 (0, banner_1.printInfo)(`Current version: \x1b[1m${version_1.VERSION}\x1b[0m`);
29 process.stdout.write(" Checking npm registry… ");
30 latest = getLatestVersion(pkg);
31 process.stdout.write(`\x1b[32m${latest}\x1b[0m\n`);
34 process.stdout.write("\n");
35 (0, banner_1.printError)(`Could not reach npm registry: ${e.message}`);
38 if (latest === version_1.VERSION) {
39 (0, banner_1.printSuccess)(`Already on the latest version (${version_1.VERSION}). Nothing to do.`);
42 console.log(`\n New version available: \x1b[32m${latest}\x1b[0m (current: \x1b[33m${version_1.VERSION}\x1b[0m)`);
43 console.log(" Installing…\n");
44 const result = (0, child_process_1.spawnSync)("npm", ["install", "-g", `${pkg}@${latest}`], {
48 if (result.status !== 0) {
49 (0, banner_1.printError)("Update failed. Try manually: npm install -g @broxium/cli");
50 if (process.platform !== "win32") {
HighRuntime Package Install
Package source invokes a package manager install command at runtime.
dist/commands/update.jsView on unpkg · L43 51 (0, banner_1.printInfo)("On macOS/Linux you may need: sudo npm install -g @broxium/cli");
56 (0, banner_1.printSuccess)(`Updated to ${latest}! Run \x1b[1mbroxium -v\x1b[0m to confirm.`);