Skip to content

Commit b148521

Browse files
committed
fix(storage): ensure tasks file exists before reading
1 parent 29fcfae commit b148521

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/utils/extras.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ export async function readJsonFileAsync<T = unknown>(
195195
filePath: string,
196196
): Promise<T> {
197197
try {
198+
const fileExists = fs.existsSync(filePath);
199+
if (!fileExists) {
200+
await writeFileAsync(filePath, JSON.stringify([]));
201+
}
198202
const data = await readFileAsync(filePath, "utf-8");
199203
return JSON.parse(data) as T;
200204
} catch (error) {

0 commit comments

Comments
 (0)