-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,
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,