Socket
Socket
Sign inDemoInstall

tar-fs

Package Overview
Dependencies
12
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tar-fs

filesystem bindings for tar-stream


Version published
Maintainers
1
Created

Package description

What is tar-fs?

The tar-fs npm package is a Node.js module that allows you to interact with tarball (.tar) files. It provides functionality to pack and extract tarball files using file system streams. It is a high-level module that makes it easy to create and extract tar files in a Node.js environment.

What are tar-fs's main functionalities?

Packing files into a tarball

This feature allows you to pack a directory into a tarball. The code sample demonstrates how to pack the contents of '/source/directory' into a tarball named 'archive.tar' located at '/destination/'.

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

let pack = tar.pack('/source/directory')
  .pipe(fs.createWriteStream('/destination/archive.tar'));

Extracting files from a tarball

This feature allows you to extract the contents of a tarball into a directory. The code sample demonstrates how to extract the contents of 'archive.tar' from '/source/' into the '/destination/directory'.

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

fs.createReadStream('/source/archive.tar')
  .pipe(tar.extract('/destination/directory'));

Other packages similar to tar-fs

Readme

Source

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

Keywords

FAQs

Last updated on 21 Dec 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc