UNPKG

@iexec/iapp

Version:

A CLI to guide you through the process of building an iExec iApp

25 lines 971 B
import path from 'node:path'; import fs from 'node:fs/promises'; import JSZip from 'jszip'; import { fileExists } from './fs.utils.js'; export async function extractZipToFolder(resultBuffer, outputFolder) { const zip = await JSZip().loadAsync(resultBuffer); if (!(await fileExists(outputFolder))) { await fs.mkdir(outputFolder, { recursive: true }); } for (const [relativePath, file] of Object.entries(zip.files)) { const outputPath = path.join(outputFolder, relativePath); if (file.dir) { await fs.mkdir(outputPath, { recursive: true }); } else { const content = await file.async('nodebuffer'); const fileDir = path.dirname(outputPath); if (!(await fileExists(fileDir))) { await fs.mkdir(fileDir, { recursive: true }); } await fs.writeFile(outputPath, content); } } } //# sourceMappingURL=extractZipToFolder.js.map