MCPcopy
hub / github.com/deepnote/deepnote / openInBrowser

Function openInBrowser

packages/cli/src/utils/browser.ts:12–31  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

10 * @throws Error if the browser cannot be opened
11 */
12export async function openInBrowser(url: string): Promise<void> {
13 const { command, args } = getOpenCommand(url)
14 debug(`Opening browser with command: ${command} ${args.join(' ')}`)
15
16 return new Promise((resolve, reject) => {
17 const child = spawn(command, args, { stdio: 'ignore' })
18
19 child.on('error', error => {
20 reject(new Error(`Failed to open browser: ${error.message}`))
21 })
22
23 child.on('close', code => {
24 if (code === 0) {
25 resolve()
26 } else {
27 reject(new Error(`Failed to open browser: process exited with code ${code}`))
28 }
29 })
30 })
31}
32
33/**
34 * Gets the platform-specific command and arguments to open a URL.

Callers 2

openDeepnoteFileInCloudFunction · 0.90
browser.test.tsFile · 0.90

Calls 2

debugFunction · 0.90
getOpenCommandFunction · 0.85

Tested by

no test coverage detected