Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 696 Bytes
652f343 5dfc565 652f343 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import path from "node:path"
import { completedTasksDirFilePath, pendingTasksDirFilePath } from "../config.mts"
import { readTask } from "./readTask.mts"
export const getTask = async (id: string) => {
const taskFileName = `${id}.json`
const completedTaskFilePath = path.join(completedTasksDirFilePath, taskFileName)
const pendingTaskFilePath = path.join(pendingTasksDirFilePath, taskFileName)
try {
const completedTask = await readTask(completedTaskFilePath)
return completedTask
} catch (err) {
try {
const pendingTask = await readTask(pendingTaskFilePath)
return pendingTask
} catch (err) {
throw new Error(`couldn't find task ${id}`)
}
}
} |