import fs from "fs"; export function createDirectoryContents( templatePath: string, newProjectPath: string ) { const filesToCreate = fs.readdirSync(templatePath); filesToCreate.forEach((file) => { const origFilePath = `${templatePath}/${file}`; // Get current file info const stats = fs.statSync(origFilePath); if (stats.isFile()) { const contents = fs.readFileSync(origFilePath, "utf8"); const writePath = `${newProjectPath}/${file}`; fs.writeFileSync(writePath, contents, "utf8"); } else if (stats.isDirectory()) { // Create subfolders with contents fs.mkdirSync(`${newProjectPath}/${file}`); createDirectoryContents( `${templatePath}/${file}`, `${newProjectPath}/${file}` ); } }); }