@ladislaogarcia/prisma-trpc-generator
Version:
Prisma 2+ generator to emit fully implemented tRPC routers
18 lines (16 loc) • 523 B
text/typescript
import path from 'path';
import { promises as fs } from 'fs';
export default async function removeDir(dirPath: string, onlyContent: boolean) {
const dirEntries = await fs.readdir(dirPath, { withFileTypes: true });
await Promise.all(
dirEntries.map(async (dirEntry) => {
const fullPath = path.join(dirPath, dirEntry.name);
return dirEntry.isDirectory()
? await removeDir(fullPath, false)
: await fs.unlink(fullPath);
}),
);
if (!onlyContent) {
await fs.rmdir(dirPath);
}
}