Skip to content

Commit b9d46b2

Browse files
authored
Disable opening the browser when in development mode (#177)
* remove dead code * nit: fix variable name * disable opening the page in browser when in development mode
1 parent b3fb6c0 commit b9d46b2

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

bin/serve.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ export async function serve(serveDirectory, key) {
5757
}
5858
}
5959
console.log(`hyperparam server running on http://localhost:${port}`)
60-
if (!key) openUrl(`http://localhost:${port}`)
61-
else {
62-
key = encodeURIComponent(key)
63-
openUrl(`http://localhost:${port}/files?key=${key}`)
60+
const isDev = process.env.NODE_ENV === 'development'
61+
if (!isDev) {
62+
if (!key) openUrl(`http://localhost:${port}`)
63+
else {
64+
key = encodeURIComponent(key)
65+
openUrl(`http://localhost:${port}/files?key=${key}`)
66+
}
6467
}
6568
}
6669

@@ -91,15 +94,12 @@ function handleRequest(req, serveDirectory) {
9194
} else if (pathname.startsWith('/assets/') || pathname.startsWith('/favicon') ) {
9295
// serve static files
9396
return handleStatic(`${hyperparamPath}/dist${pathname}`)
94-
// else if (pathname.startsWith('/public/')) {
95-
// // serve static files
96-
// return handleStatic(`${hyperparamPath}${pathname.replace(/^(\/public).*/, '/dist')}`)
9797
} else if (serveDirectory && pathname === '/api/store/list') {
9898
// serve file list
9999
const prefix = parsedUrl.query.prefix || ''
100100
if (Array.isArray(prefix)) return { status: 400, content: 'bad request' }
101-
const perfixPath = `${serveDirectory}/${decodeURIComponent(prefix)}`
102-
return handleListing(perfixPath)
101+
const prefixPath = `${serveDirectory}/${decodeURIComponent(prefix)}`
102+
return handleListing(prefixPath)
103103
} else if (serveDirectory && pathname === '/api/store/get') {
104104
// serve file content
105105
const key = parsedUrl.query.key || ''

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
"url": "run-p -l watch:ts watch:vite watch:url",
4444
"watch:ts": "tsc --watch",
4545
"watch:vite": "vite build --watch",
46-
"watch:serve": "nodemon bin/cli.js",
47-
"watch:url": "nodemon bin/cli.js https://hyperparam.blob.core.windows.net/hyperparam/starcoderdata-js-00000-of-00065.parquet"
46+
"watch:serve": "NODE_ENV=development nodemon bin/cli.js",
47+
"watch:url": "NODE_ENV=development nodemon bin/cli.js https://hyperparam.blob.core.windows.net/hyperparam/starcoderdata-js-00000-of-00065.parquet"
4848
},
4949
"dependencies": {
5050
"hightable": "0.12.1",

0 commit comments

Comments
 (0)