From: Jérôme Benoit Date: Sat, 12 Mar 2022 12:19:16 +0000 (+0100) Subject: watchJsonFile: ensure the argument is defined before assigning it X-Git-Tag: v1.1.55~17 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=69d65c15d8d5e8999c75e900cf5a750b8fc4e155;p=e-mobility-charging-stations-simulator.git watchJsonFile: ensure the argument is defined before assigning it Signed-off-by: Jérôme Benoit --- diff --git a/src/utils/FileUtils.ts b/src/utils/FileUtils.ts index cab28941..5c15734b 100644 --- a/src/utils/FileUtils.ts +++ b/src/utils/FileUtils.ts @@ -18,7 +18,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,