UNPKG

@nxrocks/common

Version:

Common library to share code among the `@nxrocks/*` plugins.

25 lines 847 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractFromZipStream = extractFromZipStream; const unzipper_1 = require("unzipper"); async function extractFromZipStream(zipStream, forEach) { return zipStream.pipe((0, unzipper_1.Parse)()) .on('entry', async (e) => { const entryPath = e.path; try { const entryContent = await e.buffer(); const entryType = e.type; // 'Directory' or 'File' if (entryType === 'File') { forEach(entryPath, entryContent); } else { e.autodrain(); } } catch (error) { console.error(`Error while unzipping item at '${entryPath}', error: ${error}`); } }) .promise(); } //# sourceMappingURL=zip-utils.js.map