Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/samualtnorman/lib. A collection of common utilities I need. www.npmjs.com/package/@samual/lib
Something went wrong. Try again.
1234567891011import type { Stats } from "fs"import { stat as getFileStats, readdir as readDirectory } from "fs/promises"import { resolve as resolvePath } from "path"
export const readDirectoryWithStats = async (path: string): Promise<{ path: string, name: string, stats: Stats }[]> => Promise.all((await readDirectory(path)).map(async name => { const resolvedPath = resolvePath(path, name)
return ({ path: resolvedPath, name, stats: await getFileStats(resolvedPath) }) }))