summaryrefslogtreecommitdiff
path: root/src/server/main.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/main.ts')
-rw-r--r--src/server/main.ts10
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();
}