@reliverse/rse
Version:
@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power
23 lines (22 loc) • 567 B
JavaScript
import { relinka } from "@reliverse/relinka";
import { execa } from "execa";
export async function openUrl(url) {
const platform = process.platform;
let command;
let args = [];
if (platform === "darwin") {
command = "open";
args = [url];
} else if (platform === "win32") {
command = "cmd";
args = ["/c", "start", "", url.replace(/&/g, "^&")];
} else {
command = "xdg-open";
args = [url];
}
try {
await execa(command, args, { stdio: "ignore" });
} catch {
relinka("info", `Please open ${url} in your browser.`);
}
}