File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 99  },
1010  "main" : " .vite/build/main.js" 
1111  "scripts" : {
12+     "prestart" : " npx tsx ./tools/ensure-tracks.ts" 
1213    "start" : " electron-forge start --enable-logging" 
1314    "generate-assets" : " npx tsx ./tools/index.ts" 
1415    "package" : " electron-forge package" 
Original file line number Diff line number Diff line change 1+ import  fs  from  'fs' ; 
2+ import  path  from  'path' ; 
3+ 
4+ const  tracksPath  =  path . join ( __dirname ,  '../src/frontend/components/TrackMap/tracks/tracks.json' ) ; 
5+ 
6+ // This is used to ensure that the tracks.json file exists. 
7+ // If it doesn't exist, it will create an empty one. 
8+ export  const  ensureTracksJson  =  ( )  =>  { 
9+   if  ( ! fs . existsSync ( tracksPath ) )  { 
10+     console . log ( 'Creating empty tracks.json file...' ) ; 
11+     console . warn ( 'To generate the tracks.json file, run `npm run generate-assets`' ) ; 
12+     fs . writeFileSync ( tracksPath ,  JSON . stringify ( { } ) ) ; 
13+     console . log ( 'Empty tracks.json file created successfully.' ) ; 
14+   } 
15+ } ; 
16+ 
17+ ensureTracksJson ( ) ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments