JSPM

  • Created
  • Published
  • Downloads 3105518
  • Score
    100M100P100Q189124F
  • License MIT

Extracting archives made easy

Package Exports

  • decompress

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (decompress) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

decompress Build Status

Extracting archives made easy

Install

$ npm install --save decompress

Usage

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!');
});

API

new Decompress(opts)

Creates a new Decompress instance.

opts.mode

Type: String

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

opts.strip

Type: Number

Equivalent to --strip-components for tar.

.src(files)

files

Type: Array|Buffer|String

Set the files to be extracted.

.dest(path)

path

Type: String

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

.use(plugin)

plugin

Type: Function

Add a plugin to the middleware stack.

.run(cb)

Extract your file with the given settings.

cb(err, files)

Type: Function

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

Plugins

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.

.tar()

Extract TAR files.

var Decompress = require('decompress');

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

.tarbz2()

Extract TAR.BZ files.

var Decompress = require('decompress');

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

.targz()

Extract TAR.GZ files.

var Decompress = require('decompress');

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

.zip()

Extract ZIP files.

var Decompress = require('decompress');

var decompress = new Decompress()
    .use(Decompress.zip({strip: 1}));

CLI

$ 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

License

MIT © Kevin Mårtensson