mirror of
https://git.stupid.fish/teidesu/scripts.git
synced 2025-07-28 02:32:11 +10:00
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
|
|
}
|
|
}
|