fix: clone configuration only if defined
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 23 Jul 2023 10:11:08 +0000 (12:11 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 23 Jul 2023 10:11:08 +0000 (12:11 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index 0d1534f126cd4274b3507ba37f4ed0c5c9162dbb..a0dd92ba4641a7dd0709b8ab6d3abb90174cd8c7 100644 (file)
@@ -1684,8 +1684,9 @@ export class ChargingStation {
         if (!existsSync(dirname(this.configurationFile))) {
           mkdirSync(dirname(this.configurationFile), { recursive: true });
         }
-        let configurationData: ChargingStationConfiguration =
-          cloneObject<ChargingStationConfiguration>(this.getConfigurationFromFile()!) ?? {};
+        let configurationData: ChargingStationConfiguration = this.getConfigurationFromFile()
+          ? cloneObject<ChargingStationConfiguration>(this.getConfigurationFromFile()!)
+          : {};
         if (this.getStationInfoPersistentConfiguration() && this.stationInfo) {
           configurationData.stationInfo = this.stationInfo;
         } else {