Skip to content

Commit 07d9bc3

Browse files
committed
fix: gracefully handle browser open failures
1 parent e4630b3 commit 07d9bc3

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export async function main({
4242
);
4343

4444
if (interactive) {
45-
stdout.write(`Starting UI on port ${port}...\n`);
4645
await startUI({
4746
project,
4847
releaseType,

src/ui.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { WriteStream } from 'fs';
22
import { join } from 'path';
33
import express from 'express';
4-
import open, { apps } from 'open';
4+
import open from 'open';
55

66
import {
77
restoreChangelogsForSkippedPackages,
@@ -86,8 +86,18 @@ export async function startUI({
8686

8787
const server = app.listen(port, async () => {
8888
const url = `http://localhost:${port}`;
89-
stdout.write(`UI server running at ${url}\n`);
90-
open(url, { app: { name: apps.browser } });
89+
90+
try {
91+
stdout.write(`\nAttempting to open UI in browser...`);
92+
await open(url);
93+
stdout.write(`\nUI server running at ${url}\n`);
94+
} catch (error) {
95+
stderr.write(`\n---------------------------------------------------\n`);
96+
stderr.write(`Error automatically opening browser: ${error}\n`);
97+
stderr.write(`Please open the following URL manually:\n`);
98+
stderr.write(`${url}\n`);
99+
stderr.write(`---------------------------------------------------\n\n`);
100+
}
91101
});
92102

93103
return new Promise((resolve, reject) => {

0 commit comments

Comments
 (0)