JSPM

  • Created
  • Published
  • Downloads 3105518
  • Score
    100M100P100Q189121F
  • 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');

new Decompress({mode: '755'})
    .src('foo.zip')
    .dest('dest')
    .use(Decompress.zip({strip: 1}))
    .run();

API

new Decompress(options)

Creates a new Decompress instance.

options.mode

Type: string

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

options.strip

Type: number

Equivalent to --strip-components for tar.

.src(files)

files

Type: array, buffer or 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(callback)

Extract your file with the given settings.

callback(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