spb/spbgit Public MIT
SPB Git — the platform hosting itself
JavaScript 73.9%
CSS 11.7%
Nunjucks 11.6%
Shell 2.7%
1/**2 * ─────────────────────────────────────────────3 * SPB Git — Personal Git Platform4 * ─────────────────────────────────────────────5 * Author : Simon-Pierre Boucher6 * Contact : contact@spboucher.ai7 * File : cli/commands/open.mjs8 * Purpose : `spbgit open [name]` — open the web UI in the browser9 * License : MIT © Simon-Pierre Boucher10 * ─────────────────────────────────────────────11 */1213import { execFile } from 'node:child_process';14import { platform } from 'node:os';15import pc from 'picocolors';16import { requireCliConfig } from '../lib/config.mjs';1718export function registerOpen(program) {19 program20 .command('open [name]')21 .description('open the repo page (or home) in the default browser')22 .action((name) => {23 const config = requireCliConfig();24 const url = name ? `${config.server}/${name}` : config.server;25 const opener = platform() === 'darwin' ? 'open' : platform() === 'win32' ? 'start' : 'xdg-open';26 execFile(opener, [url], (err) => {27 if (err) console.error(pc.red(`✗ Could not open browser: ${err.message}\n URL: ${url}`));28 else console.log(`${pc.green('✓')} ${url}`);29 });30 });31}32