Skip to content

Commit c6401ce

Browse files
author
Junhui Tong
committed
support edge as well
1 parent 089a307 commit c6401ce

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

jsr.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "@timepp/ev",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"exports": "./launch.ts"
55
}

launch.ts

+23-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,29 @@ async function main() {
1717
frontend.listen(webPort)
1818
}
1919

20-
const browser = args.browser || 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
21-
const cmd = new Deno.Command(browser, {
22-
args: [`--app=http://localhost:${webPort}/?apiPort=${apiPort}`, '--new-window', '--profile-directory=Default'],
23-
})
24-
const cp = cmd.spawn()
20+
const browsers = args.browser? [args.browser] :
21+
['C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
22+
'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe',
23+
'C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe']
24+
let cp: Deno.ChildProcess | null = null
25+
for (const browser of browsers) {
26+
console.log('trying to start browser:', browser)
27+
try {
28+
const cmd = new Deno.Command(browser, {
29+
args: [`--app=http://localhost:${webPort}/?apiPort=${apiPort}`, '--new-window', '--profile-directory=Default'],
30+
})
31+
cp = cmd.spawn()
32+
break
33+
} catch (e) {
34+
console.warn('error starting browser:', e)
35+
}
36+
}
37+
38+
if (!cp) {
39+
console.error('could not start browser')
40+
Deno.exit(1)
41+
}
42+
2543
console.log('browser started, pid:', cp.pid)
2644

2745
const cleanUp = async () => {

run.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pushd "%~dp0"
2-
deno run -A launch.ts
2+
deno run -A launch.ts %*
33
popd

0 commit comments

Comments
 (0)