File tree Expand file tree Collapse file tree 1 file changed +2
-12
lines changed
Expand file tree Collapse file tree 1 file changed +2
-12
lines changed Original file line number Diff line number Diff line change 1- import { exec } from "node:child_process" ;
21import { readFileSync } from "node:fs" ;
32import chalk from "chalk" ;
43import type { Command } from "commander" ;
4+ import open from "open" ;
55import { apiRequest } from "../lib/api.js" ;
66import { getBaseUrl } from "../lib/auth.js" ;
77import { renderMarkdown } from "../lib/markdown.js" ;
@@ -59,16 +59,6 @@ function readTextInput(opts: {
5959 return opts . text ;
6060}
6161
62- function openInBrowser ( url : string ) : void {
63- const cmd =
64- process . platform === "win32"
65- ? `start "" "${ url } "`
66- : process . platform === "darwin"
67- ? `open "${ url } "`
68- : `xdg-open "${ url } "` ;
69- exec ( cmd ) ;
70- }
71-
7262function extractTitleFromText ( text : string ) : { title ?: string ; body : string } {
7363 const lines = text . split ( "\n" ) ;
7464 const firstLine = lines [ 0 ] ?. trim ( ) ;
@@ -161,7 +151,7 @@ export function registerDocumentCommand(program: Command): void {
161151 . action ( async ( id : string ) => {
162152 const resolved = await resolveDocumentRef ( id ) ;
163153 const fullUrl = `${ getBaseUrl ( ) } ${ resolved . url } ` ;
164- openInBrowser ( fullUrl ) ;
154+ await open ( fullUrl ) ;
165155 console . log ( chalk . dim ( `Opened: ${ fullUrl } ` ) ) ;
166156 } ) ;
167157
You can’t perform that action at this time.
0 commit comments