Skip to content

Commit 9e379cb

Browse files
committed
fix: create web dir on build
1 parent ca157f5 commit 9e379cb

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/build.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as path from 'path'
44
import { setUpWebhooks } from './trello-netlify-bridge/setUpWebhooks'
55
import { cacheToFile } from './cache/cache-to-file'
66
import { render } from './website/render'
7+
import { promises as fs } from 'fs'
78

89
config()
910

@@ -18,10 +19,19 @@ const cacheLocation = path.join(webDir, 'cards.json')
1819
const cacheCards = cacheToFile<Card[]>(cacheLocation)
1920
const t = trelloApi({ apiKey, apiToken })
2021

21-
t.lists
22-
.cards({
23-
list: websiteContentList,
24-
})
22+
new Promise(async resolve => {
23+
try {
24+
await fs.stat(webDir)
25+
} catch {
26+
await fs.mkdir(webDir)
27+
}
28+
resolve()
29+
})
30+
.then(() =>
31+
t.lists.cards({
32+
list: websiteContentList,
33+
}),
34+
)
2535
.then(cards =>
2636
Promise.all(
2737
cards.map(card =>

src/website/render.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ export const render = async ({
4747
webDir: string
4848
srcDir: string
4949
}) => {
50-
try {
51-
await fs.stat(webDir)
52-
} catch {
53-
await fs.mkdir(webDir)
54-
}
55-
5650
const [tpl, imageAttachmentTemplate] = await Promise.all([
5751
fs.readFile(path.join(srcDir, 'index.html'), 'utf-8'),
5852
fs.readFile(path.join(srcDir, 'image.html'), 'utf-8'),

0 commit comments

Comments
 (0)