decompress

Extracting archives made easy

decompress

Extracting archives made easy

$ npm install --save decompress
var Decompress = require('decompress');
 
var decompress = new Decompress({ mode: '755' })
    .src('foo.zip')
    .dest('destFolder')
    .use(Decompress.zip({ strip: 1 }));
 
decompress.run(function (err) {
    if (err) {
        throw err;
    }
 
    console.log('Archive extracted successfully!');
});

Creates a new Decompress instance.

Type: Array|Buffer|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.

Type: Function

Extract your file with the given settings.

The callback will return an array of vinyl files in files and a Readable/Writable stream in stream.

Type: String

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

Type: Number

Equivalent to --strip-components for tar.

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