import { join } from 'path' import fs from 'fs/promises' import type { Dirent, StatsBase } from 'fs' export async function getFilesInDir(path: string): Promise> { const dir = await fs.opendir(path) const results = new Set() for await (const file of dir) { let resolvedFile: Dirent | StatsBase = file if (file.isSymbolicLink()) { resolvedFile = await fs.stat(join(path, file.name)) } if (resolvedFile.isFile()) { results.add(file.name) } } return results }