NO_AUTOPORT
This commit is contained in:
parent
1a8d422834
commit
c054ca1f82
|
|
@ -13,6 +13,7 @@
|
|||
`hype` wraps `hono` with useful features for fast prototyping:
|
||||
|
||||
- HTTP logging to the console (disable with `NO_HTTP_LOG` env variable)
|
||||
- Auto-port selection in dev mode: if the port is busy, tries the next one (disable with `NO_AUTOPORT` env variable)
|
||||
- Static files served from `pub/`
|
||||
- Page-based routing to `.tsx` files that export a `JSX` function in `./src/pages`
|
||||
- Transpile `.ts` files in `src/client/blah.ts` via `website.com/client/blah.ts`
|
||||
|
|
|
|||
|
|
@ -217,6 +217,8 @@ export class Hype<
|
|||
|
||||
// find an available port starting from the given port
|
||||
function findAvailablePort(startPort: number, maxAttempts = 100): number {
|
||||
if (process.env.NO_AUTOPORT) return startPort
|
||||
|
||||
for (let port = startPort; port < startPort + maxAttempts; port++) {
|
||||
try {
|
||||
const server = Bun.serve({ port, fetch: () => new Response() })
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user