refactor: only copy assets used at runtime in the bundle
[e-mobility-charging-stations-simulator.git] / src / utils / Configuration.ts
index 214260701bb112351a4bcf6df6f627c4cdddf0e1..6f53ef3bd92e796d7f9be4fd049df4b88f8be6d9 100644 (file)
@@ -55,7 +55,9 @@ export class Configuration {
   public static getUIServer(): UIServerConfiguration {
     if (Utils.hasOwnProp(Configuration.getConfig(), 'uiWebSocketServer')) {
       console.error(
-        chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration section 'uiWebSocketServer' usage. Use 'uiServer' instead}`
+        `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+          "Deprecated configuration section 'uiWebSocketServer' usage. Use 'uiServer' instead"
+        )}`
       );
     }
     let uiServerConfiguration: UIServerConfiguration = {
@@ -137,9 +139,9 @@ export class Configuration {
       (stationTemplateUrl: StationTemplateUrl) => {
         if (!Utils.isUndefined(stationTemplateUrl['numberOfStation'])) {
           console.error(
-            chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration key 'numberOfStation' usage for template file '${
-              stationTemplateUrl.file
-            }' in 'stationTemplateUrls'. Use 'numberOfStations' instead}`
+            `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+              `Deprecated configuration key 'numberOfStation' usage for template file '${stationTemplateUrl.file}' in 'stationTemplateUrls'. Use 'numberOfStations' instead`
+            )}`
           );
         }
       }
@@ -337,15 +339,19 @@ export class Configuration {
       !Utils.isUndefined((Configuration.getConfig()[sectionName] as Record<string, unknown>)[key])
     ) {
       console.error(
-        chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration key '${key}' usage in section '${sectionName}'${
-          logMsgToAppend.trim().length > 0 ? `. ${logMsgToAppend}` : ''
-        }}`
+        `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+          `Deprecated configuration key '${key}' usage in section '${sectionName}'${
+            logMsgToAppend.trim().length > 0 ? `. ${logMsgToAppend}` : ''
+          }`
+        )}`
       );
     } else if (!Utils.isUndefined(Configuration.getConfig()[key])) {
       console.error(
-        chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration key '${key}' usage${
-          logMsgToAppend.trim().length > 0 ? `. ${logMsgToAppend}` : ''
-        }}`
+        `${chalk.green(Configuration.logPrefix())} ${chalk.red(
+          `Deprecated configuration key '${key}' usage${
+            logMsgToAppend.trim().length > 0 ? `. ${logMsgToAppend}` : ''
+          }`
+        )}`
       );
     }
   }
@@ -413,10 +419,14 @@ export class Configuration {
       case 'EACCES':
         logMsg = `${fileType} file ${file} access denied:`;
         break;
+      case 'EPERM':
+        logMsg = `${fileType} file ${file} permission denied:`;
+        break;
       default:
         logMsg = `${fileType} file ${file} error:`;
     }
-    console.warn(`${chalk.green(prefix)}${chalk.yellow(`${logMsg} `)}`, error);
+    console.error(`${chalk.green(prefix)}${chalk.red(`${logMsg} `)}`, error);
+    throw error;
   }
 
   private static getDefaultPerformanceStorageUri(storageType: StorageType) {