Skip to content

Commit

Permalink
support edge as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Junhui Tong committed Jul 15, 2024
1 parent 089a307 commit c6401ce
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion jsr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@timepp/ev",
"version": "0.1.2",
"version": "0.1.3",
"exports": "./launch.ts"
}
28 changes: 23 additions & 5 deletions launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,29 @@ async function main() {
frontend.listen(webPort)
}

const browser = args.browser || 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
const cmd = new Deno.Command(browser, {
args: [`--app=http://localhost:${webPort}/?apiPort=${apiPort}`, '--new-window', '--profile-directory=Default'],
})
const cp = cmd.spawn()
const browsers = args.browser? [args.browser] :
['C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe',
'C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe']
let cp: Deno.ChildProcess | null = null
for (const browser of browsers) {
console.log('trying to start browser:', browser)
try {
const cmd = new Deno.Command(browser, {
args: [`--app=http://localhost:${webPort}/?apiPort=${apiPort}`, '--new-window', '--profile-directory=Default'],
})
cp = cmd.spawn()
break
} catch (e) {
console.warn('error starting browser:', e)
}
}

if (!cp) {
console.error('could not start browser')
Deno.exit(1)
}

console.log('browser started, pid:', cp.pid)

const cleanUp = async () => {
Expand Down
2 changes: 1 addition & 1 deletion run.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pushd "%~dp0"
deno run -A launch.ts
deno run -A launch.ts %*
popd

0 comments on commit c6401ce

Please sign in to comment.