Merge pull request #783 from SAP/dependabot/npm_and_yarn/mikro-orm/sqlite-5.8.8
[e-mobility-charging-stations-simulator.git] / src / utils / Configuration.ts
index 53eb720ffdf6f467295406f6a3a47ab3ec51d18d..d994422b07bf91e176fd7d36bc680318fadabc4c 100644 (file)
@@ -42,6 +42,11 @@ type ConfigurationSectionType =
   | WorkerConfiguration
   | UIServerConfiguration;
 
+// Avoid ESM race condition at class initialization
+const configurationLogPrefix = (): string => {
+  return logPrefix(' Simulator configuration |');
+};
+
 export class Configuration {
   public static configurationChangeCallback: () => Promise<void>;
 
@@ -118,10 +123,6 @@ export class Configuration {
     );
   }
 
-  private static logPrefix = (): string => {
-    return logPrefix(' Simulator configuration |');
-  };
-
   private static isConfigurationSectionCached(sectionName: ConfigurationSection): boolean {
     return Configuration.configurationSectionCache.has(sectionName);
   }
@@ -330,7 +331,7 @@ export class Configuration {
       (stationTemplateUrl: StationTemplateUrl) => {
         if (!isUndefined(stationTemplateUrl?.['numberOfStation' as keyof StationTemplateUrl])) {
           console.error(
-            `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+            `${chalk.green(configurationLogPrefix())} ${chalk.red(
               `Deprecated configuration key 'numberOfStation' usage for template file '${stationTemplateUrl.file}' in 'stationTemplateUrls'. Use 'numberOfStations' instead`,
             )}`,
           );
@@ -410,7 +411,7 @@ export class Configuration {
       ('staticPool' as WorkerProcessType)
     ) {
       console.error(
-        `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+        `${chalk.green(configurationLogPrefix())} ${chalk.red(
           `Deprecated configuration 'staticPool' value usage in worker section 'processType' field. Use '${WorkerProcessType.fixedPool}' value instead`,
         )}`,
       );
@@ -475,7 +476,7 @@ export class Configuration {
     // uiServer section
     if (hasOwnProp(Configuration.getConfigurationData(), 'uiWebSocketServer')) {
       console.error(
-        `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+        `${chalk.green(configurationLogPrefix())} ${chalk.red(
           `Deprecated configuration section 'uiWebSocketServer' usage. Use '${ConfigurationSection.uiServer}' instead`,
         )}`,
       );
@@ -502,7 +503,7 @@ export class Configuration {
       )
     ) {
       console.error(
-        `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+        `${chalk.green(configurationLogPrefix())} ${chalk.red(
           `Deprecated configuration key '${key}' usage in section '${sectionName}'${
             logMsgToAppend.trim().length > 0 ? `. ${logMsgToAppend}` : ''
           }`,
@@ -512,7 +513,7 @@ export class Configuration {
       !isUndefined(Configuration.getConfigurationData()?.[key as keyof ConfigurationData])
     ) {
       console.error(
-        `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+        `${chalk.green(configurationLogPrefix())} ${chalk.red(
           `Deprecated configuration key '${key}' usage${
             logMsgToAppend.trim().length > 0 ? `. ${logMsgToAppend}` : ''
           }`,
@@ -535,7 +536,7 @@ export class Configuration {
           Configuration.configurationFile,
           FileType.Configuration,
           error as NodeJS.ErrnoException,
-          Configuration.logPrefix(),
+          configurationLogPrefix(),
         );
       }
     }
@@ -560,7 +561,7 @@ export class Configuration {
         Configuration.configurationFile,
         FileType.Configuration,
         error as NodeJS.ErrnoException,
-        Configuration.logPrefix(),
+        configurationLogPrefix(),
       );
     }
   }