@dpkit/file
Version:
Fast TypeScript data management framework built on top of the Data Package standard and Polars DataFrames
19 lines (15 loc) • 373 B
text/typescript
import { access } from "node:fs/promises"
export async function isLocalPathExist(path: string) {
try {
await access(path)
return true
} catch (error) {
return false
}
}
export async function assertLocalPathVacant(path: string) {
const isExist = await isLocalPathExist(path)
if (isExist) {
throw new Error(`Path "${path}" already exists`)
}
}