diff options
| author | Pawel Zelawski <pawel@pzelawski.com> | 2026-05-23 11:34:15 +0200 |
|---|---|---|
| committer | Pawel Zelawski <pawel@pzelawski.com> | 2026-05-23 11:34:15 +0200 |
| commit | ca7452469f68d7c36a5d29eb3aca93023d021d1c (patch) | |
| tree | 3800ef6f08ae0dd0f4aa4d28156f6f937840458c /src/server/main.ts | |
| parent | 236a87f89e97b55a0c42ae4e3178da9086ebda25 (diff) | |
Diffstat (limited to 'src/server/main.ts')
| -rw-r--r-- | src/server/main.ts | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/server/main.ts b/src/server/main.ts index ecd07fd..2928375 100644 --- a/src/server/main.ts +++ b/src/server/main.ts @@ -32,11 +32,6 @@ const defaultConfig: AppConfig = { nodeEnv: process.env.NODE_ENV ?? 'development', }; -const isMainModule = () => { - if (!process.argv[1]) return false; - return import.meta.url === new URL(`file://${process.argv[1]}`).href; -}; - export function createApp(configOverrides: Partial<AppConfig> = {}) { const config: AppConfig = { ...defaultConfig, ...configOverrides }; const isProduction = config.nodeEnv === 'production'; @@ -310,6 +305,9 @@ export function startServer() { }); } -if (isMainModule()) { +const shouldAutoStart = + process.env.NODE_ENV !== 'test' && process.env.VITEST !== 'true'; + +if (shouldAutoStart) { startServer(); } |
