Apply dependencies update
[e-mobility-charging-stations-simulator.git] / src / utils / FileUtils.ts
index cab28941e730f831ed58f3639863ecfa97767bfd..b057d7f7e844b4684f823903bc22a60f98e200dd 100644 (file)
@@ -1,15 +1,14 @@
-import { JsonType, JsonValue } from '../types/JsonType';
-
 import { EmptyObject } from '../types/EmptyObject';
 import { FileType } from '../types/FileType';
 import { HandleErrorParams } from '../types/Error';
+import { JsonType } from '../types/JsonType';
 import Utils from './Utils';
 import chalk from 'chalk';
 import fs from 'fs';
 import logger from './Logger';
 
 export default class FileUtils {
-  static watchJsonFile<T extends JsonType | JsonValue>(
+  static watchJsonFile<T extends JsonType>(
     logPrefix: string,
     fileType: FileType,
     file: string,
@@ -18,7 +17,7 @@ export default class FileUtils {
       if (filename && event === 'change') {
         try {
           logger.debug(logPrefix + ' ' + fileType + ' file ' + file + ' have changed, reload');
-          attribute = JSON.parse(fs.readFileSync(file, 'utf8')) as T;
+          attribute && (attribute = JSON.parse(fs.readFileSync(file, 'utf8')) as T);
         } catch (error) {
           FileUtils.handleFileException(logPrefix, fileType, file, error as NodeJS.ErrnoException, {
             throwError: false,