JSPM

  • Created
  • Published
  • Downloads 27426283
  • Score
    100M100P100Q228712F

filesystem bindings for tar-stream

Package Exports

  • tar-fs

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 (tar-fs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

tar-fs

filesystem bindings for tar-stream.

npm install tar-fs

build status

Usage

tar-fs allows you to pack directories into tarballs and extract tarballs into directories.

var tar = require('tar-fs');
var fs = require('fs');

// packing a directory
tar.pack('./my-directory').pipe(fs.createWriteStream('my-tarball.tar'));

// extracting a directory
fs.createReadStream('my-other-tarball.tar').pipe(tar.extract('./my-other-directory'));

To ignore various files when packing or extracting add a ignore function to the options

var pack = tar.pack('./my-directory', {
    ignore: function(name) {
        return path.extname(name) === '.bin'; // ignore .bin files when packing
    }
});

var extract = tar.extract('./my-other-directory', {
    ignore: function(name) {
        return path.extname(name) === '.bin'; // ignore .bin files inside the tarball when extracing
    }
});

Copy a directory

Copying a directory with permissions and mtime intact is as simple as

tar.pack('source-directory').pipe(tar.extract('dest-directory'));

License

MIT