Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | /**
* Cross-platform browser opener.
*/
import { execFile } from 'node:child_process';
import { platform } from 'node:os';
/**
* Open a URL in the default browser.
* Returns a promise that resolves when the browser open command has been executed.
* Uses execFile (no shell) to avoid command injection via URL.
*/
export function openBrowser(url: string): Promise<void> {
return new Promise((resolve, reject) => {
const os = platform();
let command: string;
let args: string[];
switch (os) {
case 'darwin':
command = 'open';
args = [url];
break;
case 'win32':
command = 'cmd';
args = ['/c', 'start', '', url];
break;
default:
// Linux and others
command = 'xdg-open';
args = [url];
break;
}
execFile(command, args, (error) => {
if (error) {
reject(error);
} else {
resolve();
}
});
});
}
|