From 69d65c15d8d5e8999c75e900cf5a750b8fc4e155 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 12 Mar 2022 13:19:16 +0100 Subject: [PATCH] watchJsonFile: ensure the argument is defined before assigning it MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/utils/FileUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, -- 2.34.1