How to use the unzipper.ParseOne function in unzipper

To help you get started, we’ve selected a few unzipper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MindPointGroup / stig-cli / src / utils / update-sources.js View on Github external
debug('ERROR')
            debug(`No xccdf found in ${archivePath}`)
            unlinkSync(desiredFile)
            reject(err)
          })
          .pipe(createWriteStream(desiredFile))
          .on('finish', () => {
            resolve({ data: 'complete' })
          })
      } else {
        // for some reason Apple Workstation 10.8 STIGs xccdf is zipped up
        // inside a zip. ¯\_(ツ)_/¯
        debug('Working on a zip inside a zip')
        const secondZipPath = archivePath.replace('.zip', '-secondary.zip')
        createReadStream(archivePath)
          .pipe(unzipper.ParseOne(/.*.zip/i)) // nested ZIP archives YAY!
          .on('error', err => {
            debug(err)
            debug('ERROR')
            unlinkSync()
            reject(err)
          })
          .pipe(createWriteStream(secondZipPath))
          .on('finish', () => {
            createReadStream(secondZipPath)
              .pipe(unzipper.ParseOne(/.*Manual-xccdf.xml/i))
              .on('error', err => {
                debug(err)
                debug('ERROR')
                unlinkSync()
                return reject(err)
              })
github MindPointGroup / stig-cli / src / utils / update-sources.js View on Github external
return new Promise((resolve, reject) => {
    try {
      if (!archivePath.includes('U_Apple_OS_X_10-8')) {
        createReadStream(archivePath)
          .pipe(unzipper.ParseOne(/.*Manual-xccdf.xml/i))
          .on('error', err => {
            debug(err)
            debug('ERROR')
            debug(`No xccdf found in ${archivePath}`)
            unlinkSync(desiredFile)
            reject(err)
          })
          .pipe(createWriteStream(desiredFile))
          .on('finish', () => {
            resolve({ data: 'complete' })
          })
      } else {
        // for some reason Apple Workstation 10.8 STIGs xccdf is zipped up
        // inside a zip. ¯\_(ツ)_/¯
        debug('Working on a zip inside a zip')
        const secondZipPath = archivePath.replace('.zip', '-secondary.zip')
github fastify / fastify-compress / index.js View on Github external
return peek({ newline: false, maxBuffer: 10 }, function (data, swap) {
    if (maxRecursion < 0) return swap(new Error('Maximum recursion reached'))
    switch (isCompressed(data)) {
      case 1: return swap(null, pumpify(inflate.gzip(), unzipStream(inflate, maxRecursion - 1)))
      case 2: return swap(null, pumpify(inflate.deflate(), unzipStream(inflate, maxRecursion - 1)))
      case 3: return swap(null, pumpify(unZipper.ParseOne(), unzipStream(inflate, maxRecursion - 1)))
    }
    return swap(null, new Minipass())
  })
}
github adelphes / android-dev-ext / src / debugMain.js View on Github external
const readAPKManifest = (cb) => {
            D(`Reading APK Manifest`);
            const apk_manifest_chunks = [];
            function cb_once(err, manifest) {
                cb && cb(err, manifest);
                cb = null;
            }
            fs.createReadStream(this.apk_fpn)
                .pipe(unzipper.ParseOne(/^AndroidManifest\.xml$/))
                .on('data', chunk => {
                    apk_manifest_chunks.push(chunk);
                })
                .once('error', err => {
                    cb_once(err);
                })
                .once('end', () => {
                    try {
                        const manifest = decode_binary_xml(Buffer.concat(apk_manifest_chunks));
                        D(`APK manifest read complete`);
                        cb_once(null, manifest);
                    } catch (err) {
                        D(`APK manifest decode failed: ${err.message}`);
                        cb_once(err);
                    }
                });

unzipper

Unzip cross-platform streaming API

MIT
Latest version published 4 months ago

Package Health Score

79 / 100
Full package analysis