Skip to content

Commit 1945305

Browse files
committed
Fix error when ./build/cache doesn't exit
1 parent 938de3a commit 1945305

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

build/src/cache.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import crypto from 'crypto'
44
const cacheDir = './build/cache'
55

66
const cache: Record<string, () => Promise<Buffer>> = {}
7+
8+
await fs.promises.mkdir(cacheDir, { recursive: true })
79
for (const path of await fs.promises.readdir(cacheDir)) {
810
const tagHash = path.slice(0, -'.cache'.length)
911
cache[tagHash] = () => readFromDisk(tagHash)
@@ -33,7 +35,6 @@ export async function get(tag: string, download: () => Promise<Buffer>): Promise
3335
}
3436

3537
async function write(tagHash: string, data: Buffer) {
36-
await fs.promises.mkdir(cacheDir, { recursive: true })
3738
await fs.promises.writeFile(file(tagHash), data)
3839
}
3940

0 commit comments

Comments
 (0)