a reactive (signals based) hypermedia web framework (wip) stormlightlabs.github.io/volt/
hypermedia frontend signals
at main 787 B view raw
1import { mkdir, writeFile } from "node:fs/promises"; 2import path from "node:path"; 3 4/** 5 * Create a file with the given content at the specified path. 6 * 7 * Creates parent directories if they don't exist. 8 */ 9export async function createFile(filePath: string, content: string): Promise<void> { 10 const dir = path.dirname(filePath); 11 await mkdir(dir, { recursive: true }); 12 await writeFile(filePath, content, "utf8"); 13} 14 15/** 16 * Check if a directory is empty or doesn't exist. 17 */ 18export async function isEmptyOrMissing(dirPath: string): Promise<boolean> { 19 const { existsSync } = await import("node:fs"); 20 const { readdir } = await import("node:fs/promises"); 21 22 if (!existsSync(dirPath)) { 23 return true; 24 } 25 26 const files = await readdir(dirPath); 27 return files.length === 0; 28}