repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(simulator): cleanup TS configuration
[e-mobility-charging-stations-simulator.git]
/
src
/
utils
/
FileUtils.ts
diff --git
a/src/utils/FileUtils.ts
b/src/utils/FileUtils.ts
index 51871884ccc38e7c7b6d09c7d6cd37c1a6ad3192..5e40b72435bc461b5ca8a6494ee08541be830a56 100644
(file)
--- a/
src/utils/FileUtils.ts
+++ b/
src/utils/FileUtils.ts
@@
-1,4
+1,4
@@
-import
fs
from 'node:fs';
+import
{ type FSWatcher, type WatchListener, readFileSync, watch }
from 'node:fs';
import { handleFileException } from './ErrorUtils';
import { logger } from './Logger';
import { handleFileException } from './ErrorUtils';
import { logger } from './Logger';
@@
-10,11
+10,11
@@
export const watchJsonFile = <T extends JsonType>(
fileType: FileType,
logPrefix: string,
refreshedVariable?: T,
fileType: FileType,
logPrefix: string,
refreshedVariable?: T,
- listener:
fs.
WatchListener<string> = (event, filename) => {
+ listener: WatchListener<string> = (event, filename) => {
if (Utils.isNotEmptyString(filename) && event === 'change') {
try {
logger.debug(`${logPrefix} ${fileType} file ${file} have changed, reload`);
if (Utils.isNotEmptyString(filename) && event === 'change') {
try {
logger.debug(`${logPrefix} ${fileType} file ${file} have changed, reload`);
- refreshedVariable && (refreshedVariable = JSON.parse(
fs.
readFileSync(file, 'utf8')) as T);
+ refreshedVariable && (refreshedVariable = JSON.parse(readFileSync(file, 'utf8')) as T);
} catch (error) {
handleFileException(file, fileType, error as NodeJS.ErrnoException, logPrefix, {
throwError: false,
} catch (error) {
handleFileException(file, fileType, error as NodeJS.ErrnoException, logPrefix, {
throwError: false,
@@
-22,10
+22,10
@@
export const watchJsonFile = <T extends JsonType>(
}
}
}
}
}
}
-):
fs.
FSWatcher | undefined => {
+): FSWatcher | undefined => {
if (Utils.isNotEmptyString(file)) {
try {
if (Utils.isNotEmptyString(file)) {
try {
- return
fs.
watch(file, listener);
+ return watch(file, listener);
} catch (error) {
handleFileException(file, fileType, error as NodeJS.ErrnoException, logPrefix, {
throwError: false,
} catch (error) {
handleFileException(file, fileType, error as NodeJS.ErrnoException, logPrefix, {
throwError: false,