Refactor out file helpers into fs.ts

This commit is contained in:
Saoud Rizwan
2024-09-29 02:25:22 -04:00
parent ebead1b1fa
commit 2b63b91bfb
6 changed files with 107 additions and 117 deletions

View File

@@ -8,6 +8,7 @@ import TurndownService from "turndown"
import PCR from "puppeteer-chromium-resolver"
import pWaitFor from "p-wait-for"
import delay from "delay"
import { fileExistsAtPath } from "../../utils/fs"
interface PCRStats {
puppeteer: { launch: typeof launch }
@@ -30,10 +31,7 @@ export class UrlContentFetcher {
}
const puppeteerDir = path.join(globalStoragePath, "puppeteer")
const dirExists = await fs
.access(puppeteerDir)
.then(() => true)
.catch(() => false)
const dirExists = await fileExistsAtPath(puppeteerDir)
if (!dirExists) {
await fs.mkdir(puppeteerDir, { recursive: true })
}