INNER CODE UNIT · TypeScript

copyDir

gimlet-io/capacitor · bundle.ts:71

async function copyDir(src: string, dest: string): Promise<void> {
    await Deno.mkdir(dest, { recursive: true });
    for await (const entry of Deno.readDir(src)) {
        const srcPath = `${src}/${entry.name}`;
        const destPath = `${dest}/${entry.name}`;
        if (entry.isDirectory) {
            await copyDir(srcPath, destPath);
        } else if (entry.isFile) {
            const data = await Deno.readFile(srcPath);
            await Deno.writeFile(destPath, data);
        }
    }
}

// Clean and prepare bundle directory
try { await Deno.remove("bundle", { recursive: true }); } catch (_) { /* ignore */ }
await Deno.mkdir("bundle", { recursive: true });
await copyDir("public", "bundle");

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…