node/deps/npm/node_modules/tar/README.md

49 lines
1.1 KiB
Markdown
Raw Normal View History

# node-tar
Tar for Node.js.
2013-12-12 02:20:26 +08:00
[![NPM](https://nodei.co/npm/tar.png)](https://nodei.co/npm/tar/)
2013-12-12 02:20:26 +08:00
## API
2013-12-12 02:20:26 +08:00
See `examples/` for usage examples.
2013-12-12 02:20:26 +08:00
### var tar = require('tar')
2013-12-12 02:20:26 +08:00
Returns an object with `.Pack`, `.Extract` and `.Parse` methods.
2013-12-12 02:20:26 +08:00
### tar.Pack([properties])
2013-12-12 02:20:26 +08:00
Returns a through stream. Use
[fstream](https://npmjs.org/package/fstream) to write files into the
pack stream and you will receive tar archive data from the pack
stream.
2014-08-01 00:05:30 +08:00
This only works with directories, it does not work with individual files.
2013-12-12 02:20:26 +08:00
The optional `properties` object are used to set properties in the tar
'Global Extended Header'.
2013-12-12 02:20:26 +08:00
### tar.Extract([options])
2013-12-12 02:20:26 +08:00
Returns a through stream. Write tar data to the stream and the files
in the tarball will be extracted onto the filesystem.
2013-12-12 02:20:26 +08:00
`options` can be:
2013-12-12 02:20:26 +08:00
```js
{
path: '/path/to/extract/tar/into',
strip: 0, // how many path segments to strip from the root when extracting
}
```
2013-12-12 02:20:26 +08:00
`options` also get passed to the `fstream.Writer` instance that `tar`
uses internally.
2013-12-12 02:20:26 +08:00
### tar.Parse()
2013-12-12 02:20:26 +08:00
Returns a writable stream. Write tar data to it and it will emit
`entry` events for each entry parsed from the tarball. This is used by
`tar.Extract`.