19 lines
398 B
TypeScript
19 lines
398 B
TypeScript
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
|
|
}
|
|
}
|