diff --git a/bin/serve.js b/bin/serve.js index 8e1295a6..94a69789 100644 --- a/bin/serve.js +++ b/bin/serve.js @@ -56,14 +56,11 @@ export async function serve(serveDirectory, key) { port++ } } - console.log(`hyperparam server running on http://localhost:${port}`) - const isDev = process.env.NODE_ENV === 'development' - if (!isDev) { - if (!key) openUrl(`http://localhost:${port}`) - else { - key = encodeURIComponent(key) - openUrl(`http://localhost:${port}/files?key=${key}`) - } + const path = key ? `/files?key=${encodeURIComponent(key)}` : '/' + const url = `http://localhost:${port}${path}` + console.log(`hyperparam server running on ${url}`) + if (process.env.NODE_ENV !== 'development') { + openUrl(url) } } diff --git a/package.json b/package.json index 005dd51c..8b372e5f 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "test": "vitest run", "typecheck": "tsc --noEmit", "url": "run-p -l watch:ts watch:vite watch:url", + "preurl": "npm run build", "watch:ts": "tsc --watch", "watch:vite": "vite build --watch", "watch:serve": "NODE_ENV=development nodemon bin/cli.js",