@@ -10,6 +10,9 @@ const apiKey = process.env.API_KEY!;
1010const apiToken = process . env . API_TOKEN ! ;
1111const websiteContentList = process . env . WEBSITE_CONTENT_LIST ! ;
1212
13+ const srcDir = path . join ( __dirname , '..' , 'src' ) ;
14+ const webDir = path . join ( __dirname , '..' , 'web' ) ;
15+
1316const fetchContentFromTrello = async ( ) => {
1417 const cards = await trelloApi ( { apiKey, apiToken } ) . lists . cards ( {
1518 list : websiteContentList ,
@@ -23,11 +26,14 @@ fetchContentFromTrello()
2326 )
2427 . then ( content => new showdown . Converter ( ) . makeHtml ( content ) )
2528 . then ( async contentAsMarkdown => {
26- const tpl = await fs . readFile (
27- path . join ( __dirname , '..' , 'src' , 'index.html' ) ,
28- 'utf-8' ,
29- ) ;
30- const targetFile = path . join ( __dirname , '..' , 'web' , 'index.html' ) ;
29+ try {
30+ await fs . stat ( webDir ) ;
31+ } catch {
32+ await fs . mkdir ( webDir ) ;
33+ }
34+
35+ const tpl = await fs . readFile ( path . join ( srcDir , 'index.html' ) , 'utf-8' ) ;
36+ const targetFile = path . join ( webDir , 'index.html' ) ;
3137 await fs . writeFile (
3238 targetFile ,
3339 tpl . replace ( '{{content}}' , contentAsMarkdown ) ,
0 commit comments