X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils%2FFileUtils.ts;h=b057d7f7e844b4684f823903bc22a60f98e200dd;hb=67eb544324cd655b9dca3cfd9fa854789d7c5924;hp=cab28941e730f831ed58f3639863ecfa97767bfd;hpb=a95873d8d308a20a7151346ac70d9a551f1a06f5;p=e-mobility-charging-stations-simulator.git diff --git a/src/utils/FileUtils.ts b/src/utils/FileUtils.ts index cab28941..b057d7f7 100644 --- a/src/utils/FileUtils.ts +++ b/src/utils/FileUtils.ts @@ -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( + static watchJsonFile( 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,