refactor: factor out performance records JSON file path building
[e-mobility-charging-stations-simulator.git] / src / charging-station / Bootstrap.ts
index 6be5d275682b3e5bdf5ead54916334d94825ebee..653a8ddbc1f85fdcd84b29a47b278e44864385bf 100644 (file)
@@ -7,7 +7,7 @@ import { type Worker, isMainThread } from 'node:worker_threads';
 import chalk from 'chalk';
 
 import { type AbstractUIServer, ChargingStationUtils, UIServerFactory } from './internal';
-import { version } from '../../package.json';
+import packageJson from '../../package.json' assert { type: 'json' };
 import { BaseError } from '../exception';
 import { type Storage, StorageFactory } from '../performance';
 import {
@@ -37,7 +37,7 @@ export class Bootstrap {
   private readonly uiServer!: AbstractUIServer | null;
   private readonly storage!: Storage;
   private numberOfStartedChargingStations!: number;
-  private readonly version: string = version;
+  private readonly version: string = packageJson.version;
   private initializedCounters: boolean;
   private started: boolean;
   private readonly workerScript: string;
@@ -236,9 +236,9 @@ export class Bootstrap {
       const stationTemplateUrls = Configuration.getStationTemplateUrls();
       if (Utils.isNotEmptyArray(stationTemplateUrls)) {
         this.numberOfChargingStationTemplates = stationTemplateUrls.length;
-        stationTemplateUrls.forEach((stationTemplateUrl) => {
+        for (const stationTemplateUrl of stationTemplateUrls) {
           this.numberOfChargingStations += stationTemplateUrl.numberOfStations ?? 0;
-        });
+        }
       } else {
         console.warn(
           chalk.yellow("'stationTemplateUrls' not defined or empty in configuration, exiting")