refactor: add sanity check to worker script handling
[e-mobility-charging-stations-simulator.git] / src / worker / WorkerAbstract.ts
index 3dd9a782a8661507f61fa21787ed9f80c9465852..16d566bde2ae60049fe401c7f13f830af4ce17dd 100644 (file)
@@ -27,9 +27,12 @@ export abstract class WorkerAbstract<T extends WorkerData> {
       messageHandler: WorkerConstants.EMPTY_FUNCTION,
     }
   ) {
-    if (!workerScript) {
+    if (workerScript === null || workerScript === undefined) {
       throw new Error('Worker script is not defined');
     }
+    if (typeof workerScript === 'string' && workerScript.trim().length === 0) {
+      throw new Error('Worker script is empty');
+    }
     if (!fs.existsSync(workerScript)) {
       throw new Error('Worker script file does not exist');
     }