scripts/utils/fs.ts

20 lines
398 B
TypeScript
Raw Normal View History

2025-01-14 05:38:00 +03:00
import * as fsp from 'node:fs/promises'
export async function fileExists(path: string): Promise<boolean> {
try {
const stat = await fsp.stat(path)
return stat.isFile()
} catch {
return false
}
}
export async function directoryExists(path: string): Promise<boolean> {
try {
const stat = await fsp.stat(path)
return stat.isDirectory()
} catch {
return false
}
}