decompress

Extracting archives made easy

decompress

Extracting archives made easy

$ npm install --save decompress
var Decompress = require('decompress');
 
new Decompress({mode: '755'})
    .src('foo.zip')
    .dest('dest')
    .use(Decompress.zip({strip: 1}))
    .run();

Creates a new Decompress instance.

Type: string

Set mode on the extracted files, i.e { mode: '755' }.

Type: number

Equivalent to --strip-components for tar.

Type: array, buffer or string

Set the files to be extracted.

Type: string

Set the destination to where your file will be extracted to.

Type: function

Add a plugin to the middleware stack.

Extract your file with the given settings.

Type: function

The callback will return an array of vinyl files in files.

The following plugins are bundled with decompress:

  • tar — Extract TAR files.
  • tar.bz2 — Extract TAR.BZ files.
  • tar.gz — Extract TAR.GZ files.
  • zip — Extract ZIP files.

Extract TAR files.

var Decompress = require('decompress');
 
var decompress = new Decompress()
    .use(Decompress.tar({strip: 1}));

Extract TAR.BZ files.

var Decompress = require('decompress');
 
var decompress = new Decompress()
    .use(Decompress.tarbz2({strip: 1}));

Extract TAR.GZ files.

var Decompress = require('decompress');
 
var decompress = new Decompress()
    .use(Decompress.targz({strip: 1}));

Extract ZIP files.

var Decompress = require('decompress');
 
var decompress = new Decompress()
    .use(Decompress.zip({strip: 1}));
$ npm install --global decompress
$ decompress --help
 
  Usage
    $ decompress <file> [directory]
    $ cat <file> | decompress [directory]
 
  Example
    $ decompress --strip 1 file.zip out
    $ cat file.zip | decompress out
 
  Options
    -m, --mode     Set mode on the extracted files
    -s, --strip    Equivalent to --strip-components for tar

MIT © Kevin Mårtensson