How to use yazl - 10 common examples

To help you get started, we’ve selected a few yazl 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 electrode-io / electrode-ota-server / electrode-ota-server-model-manifest / src / manifest.js View on Github external
yauzl[method](buffer, { lazyEntries: true }, function (err, zipfile) {
            const seen = [];
            // this is to make react native code push work right
            if (err) return reject(err);
            const retFile = new yazl.ZipFile();

            zipfile.readEntry();
            zipfile.on("entry", function (entry) {
                if (/\/$/.test(entry.fileName)) {
                    zipfile.readEntry();
                    return;
                }
                // file entry
                zipfile.openReadStream(entry, function (err, readStream) {
                    if (err) throw err;
                    streamHash(readStream).then(hash => {
                        seen.push(entry.fileName);
                        if (hash !== manifest[entry.fileName]) {
                            zipfile.openReadStream(entry, (e, readFromStream) => {
                                const mtime = entry.getLastModDate();
                                retFile.addReadStream(readFromStream, entry.fileName, { mtime });
github microsoft / vscode-react-native / src / extension / appcenter / lib / codepush-node-sdk / dist / update-contents / zip.js View on Github external
}
        const directoryPath = updateContentsPath;
        const baseDirectoryPath = path.join(directoryPath, '..'); // For legacy reasons, put the root directory in the zip
        const files = yield fileUtils.walk(updateContentsPath);
        files.forEach((filePath) => {
            const relativePath = path.relative(baseDirectoryPath, filePath);
            releaseFiles.push({
                sourceLocation: filePath,
                targetLocation: fileUtils.normalizePath(relativePath)
            });
        });
        if (!outputDir) {
            outputDir = process.cwd();
        }
        const packagePath = path.join(outputDir, fileUtils.generateRandomFilename(15) + '.zip');
        const zipFile = new yazl.ZipFile();
        const writeStream = fs.createWriteStream(packagePath);
        zipFile.outputStream.pipe(writeStream)
            .on('error', (error) => {
            reject(error);
        })
            .on('close', () => {
            resolve(packagePath);
        });
        releaseFiles.forEach((releaseFile) => {
            zipFile.addFile(releaseFile.sourceLocation, releaseFile.targetLocation);
        });
        zipFile.end();
    }));
}
github evansiroky / node-geo-tz / lib / update.js View on Github external
zipData: ['createIndex', function (results, cb) {
      var zipfile = new yazl.ZipFile()
      // recursively add all files in data directory to zip file
      zipDir(zipfile, path.resolve(__dirname + '/../'), dataDir, dataDir, function (err) {
        if (err) return cb(err)
        zipfile.outputStream.pipe(fs.createWriteStream(resolvedDataDir + '.zip')).on('close', cb)
        zipfile.end()
      })
    }]
  }, callback)
github microsoft / appcenter-cli / src / commands / codepush / lib / update-contents-tasks / zip.ts View on Github external
const directoryPath: string = updateContentsPath;
    const baseDirectoryPath = path.join(directoryPath, ".."); // For legacy reasons, put the root directory in the zip

    const files: string[] = await pfs.walk(updateContentsPath);

    files.forEach((filePath: string) => {
      const relativePath: string = path.relative(baseDirectoryPath, filePath);
      releaseFiles.push({
        sourceLocation: filePath,
        targetLocation: normalizePath(relativePath)
      });
    });

    const packagePath: string = path.join(process.cwd(), generateRandomFilename(15) + ".zip");
    const zipFile = new yazl.ZipFile();
    const writeStream: fs.WriteStream = fs.createWriteStream(packagePath);

    zipFile.outputStream.pipe(writeStream)
        .on("error", (error: Error): void => {
            reject(error);
        })
        .on("close", (): void => {

            resolve(packagePath);
        });

    releaseFiles.forEach((releaseFile: ReleaseFile) => {
        zipFile.addFile(releaseFile.sourceLocation, releaseFile.targetLocation);
    });

    zipFile.end();
github electrode-io / electrode-native / ern-core / src / BundleStoreEngine.ts View on Github external
public async uploadAssets() {
    const newAssets = await this.sdk.assetsDelta(this.assets.map(a => a.hash))

    if (newAssets.length > 0) {
      log.debug(`Uploading ${newAssets.length} new asset(s)`)

      const zipfile = new yazl.ZipFile()
      const tmpZipPath = path.join(createTmpDir(), 'assets.zip')
      const s = fs.createWriteStream(tmpZipPath)
      zipfile.outputStream.pipe(s)
      for (const asset of this.assets) {
        for (const file of asset.files) {
          const hash = asset.hash
          zipfile.addFile(file, path.join(hash, path.basename(file)))
        }
      }
      zipfile.end()

      const assetsProm = new Promise((resolve, reject) => {
        s.on('close', () => {
          resolve()
        })
      })
github noobaa / noobaa-core / src / util / zip_utils.js View on Github external
function zip_from_dir(dir) {
    const zipfile = new yazl.ZipFile();
    return P.resolve()
        .then(() => fs_utils.read_dir_recursive({
            root: dir,
            on_entry: entry => {
                const relative_path = path.relative(dir, entry.path);
                if (entry.stat.isFile()) {
                    zipfile.addFile(entry.path, relative_path);
                } else if (entry.stat.isDirectory()) {
                    zipfile.addEmptyDirectory(relative_path);
                }
            }
        }))
        .then(() => zipfile.end())
        .return(zipfile);
}
github AdobeXD / xdpm / commands / package.js View on Github external
if (errors.length > 0) {
            return Object.assign({}, result, {
                "error": "Can't package a plugin that has validation errors in the manifest.json:\n" + errors.join("\n")
            });
        }

        const id = metadata.id;
        if (!id) {
            return Object.assign({}, result, {
                "error": "Can't package a plugin without a plugin ID in the manifest"
            });
        }

        result.targetZip = path.join(sourcePath, '..', path.basename(sourcePath) + ".xdx");

        const zipfile = new yazl.ZipFile();

        zipfile.outputStream.pipe(fs.createWriteStream(result.targetZip)).on("close", function() {
        });

        const files = ignoreWalk.sync({
            path: sourcePath,
            ignoreFiles: [".gitignore", ".xdignore", ".npmignore"],
            includeEmpty: false,
        }).filter(filterAlwaysIgnoredFile);

        files.forEach(file => {
            zipfile.addFile(path.join(sourcePath, file), file);
        });


        zipfile.end();
github NuSkooler / enigma-bbs / core / file_base_user_list_export.js View on Github external
fse.stat(filePath, (err, stats) => {
            if(err) {
                return cb(err);
            }

            if(stats.size < this.config.compressThreshold) {
                //	small enough, keep orig
                return cb(null, filePath, stats.size);
            }

            const zipFilePath = `${filePath}.zip`;

            const zipFile = new yazl.ZipFile();
            zipFile.addFile(filePath, paths.basename(filePath));
            zipFile.end( () => {
                const outZipFile = fs.createWriteStream(zipFilePath);
                zipFile.outputStream.pipe(outZipFile);
                zipFile.outputStream.on('finish', () => {
                    //	delete the original
                    fse.unlink(filePath, err => {
                        if(err) {
                            return cb(err);
                        }

                        //	finally stat the new output
                        fse.stat(zipFilePath, (err, stats) => {
                            return cb(err, zipFilePath, stats ? stats.size : 0);
                        });
                    });
github mozilla / Spoke / package.js View on Github external
buildRelease(targets, outputDir, process.argv.slice(2)).then(() => {
  for (const platform of platforms) {
    const executableName = `spoke-${platform}`;
    const executablePath = path.join(outputDir, appendExtension(executableName, platform));
    const archivePath = path.join(outputDir, `${executableName}-v${packageJSON.version}.zip`);
    const archiveStream = fs.createWriteStream(archivePath);

    const zip = new ZipFile();
    zip.outputStream.pipe(archiveStream);
    if (platform === "macos") {
      zip.addFile(executablePath, path.join("Spoke", "runtime.bin"), { mode: 0o100775 });
      zip.addFile("src/server/launcher.sh", path.join("Spoke", "spoke"), { mode: 0o100775 });
    } else {
      zip.addFile(executablePath, path.join("Spoke", appendExtension("spoke", platform)), { mode: 0o100775 });
    }
    zip.end();
  }
});
github darkreader / darkreader / tasks / zip.js View on Github external
return new Promise((resolve) => {
        const archive = new yazl.ZipFile();
        files.forEach((file) => archive.addFile(file, file.startsWith(`${cwd}/`) ? file.substring(cwd.length + 1) : file));
        archive.outputStream.pipe(fs.createWriteStream(dest)).on('close', () => resolve());
        archive.end();
    });
}

yazl

yet another zip library for node

MIT
Latest version published 15 days ago

Package Health Score

80 / 100
Full package analysis

Popular yazl functions