Skip to content

Commit c26d3be

Browse files
committed
0serve accepts DEBUG_BROWSER env variable
1 parent dc7b786 commit c26d3be

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bin/0serve.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
#!/usr/bin/env node
2+
3+
/**
4+
* Simple http server implementation.
5+
* Optionally, you may set `DEBUG_BROWSER` environment variable to use a different browser to debug
6+
* web apps.
7+
*/
8+
29
import * as http from 'http'
310
import * as path from 'path'
411
import * as fs from 'fs'
@@ -9,6 +16,7 @@ import * as logging from 'lib0/logging'
916
const host = env.getParam('--host', 'localhost')
1017
const port = number.parseInt(env.getParam('--port', '8000'))
1118
const paramOpenFile = env.getParam('-o', '')
19+
const debugBrowser = env.getConf('DEBUG_BROWSER')
1220

1321
/**
1422
* @type {Object<string,string>}
@@ -81,7 +89,7 @@ const server = http.createServer((req, res) => {
8189
server.listen(port, host, () => {
8290
logging.print(logging.BOLD, logging.ORANGE, `Server is running on http://${host}:${port}`)
8391
if (paramOpenFile) {
84-
const start = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open'
92+
const start = debugBrowser || (process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open')
8593
import('child_process').then(cp => {
8694
cp.exec(`${start} http://${host}:${port}/${paramOpenFile}`)
8795
})

0 commit comments

Comments
 (0)