"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.unzip = void 0;
const fs_1 = __importDefault(require("fs"));
const unzipper_1 = __importDefault(require("unzipper"));
const unzip = (zipFilename, extractFilename, outputFilename) => {
    return fs_1.default
        .createReadStream(zipFilename)
        .pipe(unzipper_1.default.Parse())
        .on('entry', (entry) => {
        const fileName = entry.path;
        if (fileName === extractFilename) {
            entry.pipe(fs_1.default.createWriteStream(outputFilename));
        }
        else {
            entry.autodrain();
        }
    })
        .promise();
};
exports.unzip = unzip;
