File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 11import { 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
64const DIRECTORY_FILE = 'eventfiles/directory.json' ;
75
@@ -11,8 +9,9 @@ const namesOfEvents: Record<string, string> = await generateMapping();
119async 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() {
2423void watchForDirectoryChanges ( ) ;
2524
2625async 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 ;
You can’t perform that action at this time.
0 commit comments