Archiver

Archiver

new Archiver(format, options)

Parameters:
Name Type Description
format String

The archive format to use.

options CoreOptions | TransformOptions

See also ZipOptions and TarOptions.

Source:

Methods

abort() → {this}

Aborts the archiving process, taking a best-effort approach, by:

  • removing any pending queue tasks
  • allowing any active queue workers to finish
  • detaching internal module pipes
  • ending both sides of the Transform stream

It will NOT drain any remaining sources.

Source:
Returns:
Type
this

append(source, data) → {this}

Appends an input source (text string, buffer, or stream) to the instance.

When the instance has received, processed, and emitted the input, the entry event is fired.

Parameters:
Name Type Description
source Buffer | Stream | String

The input source.

data EntryData

See also ZipEntryData and TarEntryData.

Source:
Fires:
Returns:
Type
this

bulk(mappings) → {this}

Appends multiple entries from passed array of src-dest mappings.

A lazystream wrapper is used to prevent issues with open file limits.

Parameters:
Name Type Description
mappings Array.<Object>
Properties
Name Type Description
data EntryData | function

See also ZipEntryData and TarEntryData.

src String | Array

Pattern(s) to match, relative to the cwd.

dest String

Destination path prefix.

expand Boolean

Process a dynamic src-dest file mapping.

cwd String

All src matches are relative to (but don't include) this path. requires expand.

ext String

Replace any existing extension with this value in generated dest paths. requires expand.

extDot String

Used to indicate where the period indicating the extension is located. requires expand.

flatten String

Remove all path parts from generated dest paths. requires expand.

* *

See node-glob and minimatch documentation for additional properties.

Deprecated:
  • 0.21.0
Source:
Returns:
Type
this

directory(dirpath, destpath, data) → {this}

Appends a directory and its files, recursively, given its dirpath.

Parameters:
Name Type Description
dirpath String

The source directory path.

destpath String

The destination path within the archive.

data EntryData | function

See also ZipEntryData and TarEntryData.

Source:
Returns:
Type
this

file(filepath, data) → {this}

Appends a file given its filepath using a lazystream wrapper to prevent issues with open file limits.

When the instance has received, processed, and emitted the file, the entry event is fired.

Parameters:
Name Type Description
filepath String

The source filepath.

data EntryData

See also ZipEntryData and TarEntryData.

Source:
Returns:
Type
this

finalize() → {this}

Finalizes the instance and prevents further appending to the archive structure (queue will continue til drained).

The end, close or finish events on the destination stream may fire right after calling this method so you should set listeners beforehand to properly detect stream completion.

Source:
Returns:
Type
this

glob(pattern, options, data) → {this}

Appends multiple files that match a glob pattern.

Parameters:
Name Type Description
pattern String

The glob pattern to match.

options Object

See node-glob.

data EntryData

See also ZipEntryData and TarEntryData.

Source:
Returns:
Type
this

pointer() → {Number}

Returns the current length (in bytes) that has been emitted.

Source:
Returns:
Type
Number

setFormat(format) → {this}

Sets the module format name used for archiving.

Parameters:
Name Type Description
format String

The name of the format.

Source:
Returns:
Type
this

setModule(module) → {this}

Sets the module used for archiving.

Parameters:
Name Type Description
module function

The function for archiver to interact with.

Source:
Returns:
Type
this

Events

entry

Fires when the entry's input has been processed and appended to the archive.

Type:
Source: