Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chpio/tar-vinyl-stream
https://github.com/chpio/tar-vinyl-stream
Last synced: about 13 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/chpio/tar-vinyl-stream
- Owner: chpio
- Created: 2016-03-19T11:49:43.000Z (over 8 years ago)
- Default Branch: develop
- Last Pushed: 2019-09-05T16:44:39.000Z (about 5 years ago)
- Last Synced: 2024-10-31T18:58:31.479Z (6 days ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# tar-vinyl-stream
*tar-vinyl-stream* exposes two streams, *pack* and *extract*.
## Pack
The *pack* stream consumes a stream of *vinyl* objects and generates a tar file stream.```javascript
import {pack} from 'tar-vinyl-stream';
import * as fs from 'fs';
import gulp from 'gulp';
import debug from 'gulp-debug';gulp.src('./src/*.js')
.pipe(debug())
.pipe(pack())
.pipe(fs.createWriteStream('./my-files.tar'));
```## Extract
The *extract* stream consumes a tar stream and emits *vinyl* objects for each containing file.```javascript
import {extract} from 'tar-vinyl-stream';
import * as fs from 'fs';
import gulp from 'gulp';
import debug from 'gulp-debug';fs.createReadStream('./my-files.tar')
.pipe(extract())
.pipe(debug())
.pipe(...) // use gulp plugins
.pipe(gulp.dest('./my-tar'));
```*extract* also exposes the [tar header](https://www.npmjs.com/package/tar-stream#headers). You can use it for any purpose, eg filtering the files:
```javascript
import {extract} from 'tar-vinyl-stream';
import * as fs from 'fs';
import gulp from 'gulp';
import debug from 'gulp-debug';
import filter from 'through2-filter';fs.createReadStream('./my-files.tar')
.pipe(extract())
.pipe(debug())
// allow only files
.pipe(filter.obj(f => f.tarHeader.type === 'file'))
.pipe(debug())
.pipe(gulp.dest('./dest'));```