From e15c97360d91046202b7c819cac2c28a33aedb0d Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Tue, 22 Oct 2024 10:20:49 +0200 Subject: [PATCH] backend: Fixed start process on Windows --- backend/src/server.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/src/server.ts b/backend/src/server.ts index a8ecfda6..df0221a5 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -107,7 +107,17 @@ const startServer = (app: express.Application) => { * @returns {boolean} True if this module is the main entry point, false otherwise. */ const isMainModule = (): boolean => { - return import.meta.url === `file://${process.argv[1]}`; + const importMetaUrl = import.meta.url; + let processArgv1 = process.argv[1]; + + if (process.platform === "win32") { + processArgv1 = processArgv1.replace(/\\/g, "/"); + processArgv1 = `file:///${processArgv1}`; + } else { + processArgv1 = `file://${processArgv1}`; + } + + return importMetaUrl === processArgv1; }; if (isMainModule()) {