Skip to content

Commit 6259f1d

Browse files
committed
added log messages when directory gets (re)loaded
1 parent a841a1b commit 6259f1d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

source/lib/all-events.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import {readFile, watch} from 'node:fs/promises';
2-
import type {
3-
EventDirectory, EventId, Events,
4-
} from './types.ts';
2+
import type {EventDirectory, EventId, Events} from './types.ts';
53

64
const DIRECTORY_FILE = 'eventfiles/directory.json';
75

@@ -11,8 +9,9 @@ const namesOfEvents: Record<string, string> = await generateMapping();
119
async function watchForDirectoryChanges() {
1210
const watcher = watch(DIRECTORY_FILE);
1311
for await (const event of watcher) {
14-
console.log(event);
1512
if (event.eventType === 'change') {
13+
console.log(new Date(), 'Detected file change. Reloading...');
14+
1615
await loadDirectory();
1716
await generateMapping();
1817
}
@@ -24,6 +23,8 @@ async function watchForDirectoryChanges() {
2423
void watchForDirectoryChanges();
2524

2625
async function loadDirectory(): Promise<Partial<EventDirectory>> {
26+
console.log(new Date(), 'Loading directory');
27+
2728
const directoryString = await readFile(DIRECTORY_FILE);
2829
const directory = JSON.parse(directoryString.toString()) as Partial<EventDirectory>;
2930
return directory;

0 commit comments

Comments
 (0)