function

zlib.zipFiles

function zipFiles(
files: Iterable<readonly [string, string]>,
options?: string | ZipFilesOptions

Builds an archive from files on disk. For each [sourcePath, entryName] pair it reads sourcePath and adds an entry named entryName, capturing the file's Unix mode and modification time. A directory becomes a directory entry; a regular file's contents are streamed in (as a zlib.ZipEntry.createStream() entry) without being buffered in memory. Directory contents are not walked recursively - list each path you want included.

When followSymlinks is true (the default) a symbolic link is resolved and archived as its target file; when it is false the link itself is stored as a symbolic-link entry whose content is the target path (see zlib.ZipEntry.createSymlink()).

@param files

Iterable of [sourcePath, entryName] string pairs. Any iterable works - an array, a Map, the result of Object.entries(), a generator.

@param options

An archive comment, as a shorthand for { comment: options }.

@returns

stream.Readable of Buffer chunks making up the serialized archive.

Referenced types

interface ZipFilesOptions

  • baseOffset?: number

    Shifts every local/central header offset the archive records by this many bytes.

  • comment?: string

    An archive comment.