https://github.com/jamen/pull-vinyl
Read and write `Vinyl` objects in the file system.
https://github.com/jamen/pull-vinyl
Last synced: 9 months ago
JSON representation
Read and write `Vinyl` objects in the file system.
- Host: GitHub
- URL: https://github.com/jamen/pull-vinyl
- Owner: jamen
- License: mit
- Created: 2016-10-25T07:49:58.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-28T03:16:10.000Z (over 9 years ago)
- Last Synced: 2025-06-23T11:50:57.785Z (12 months ago)
- Language: JavaScript
- Size: 38.1 KB
- Stars: 7
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: contributing.md
- License: LICENSE
Awesome Lists containing this project
README
# pull-vinyl [](https://npmjs.org/package/pull-vinyl) [](https://travis-ci.org/jamen/pull-vinyl)
> Read and write `Vinyl` objects in the file system.
```js
pull(
// Read `Vinyl` files
vinyl.src('foo/**/*.js'),
// Transform them somehow, i.e. with a compiler.
transformVinyl(),
// Write them
vinyl.dest('output')
)
```
Reading and writing [`Vinyl`](https://github.com/gulpjs/vinyl) objects to/from the file system with pull streams. It is inspired from [`vinyl-fs`](https://github.com/gulpjs/vinyl-fs) from gulp.
## Installation
```sh
$ npm install --save pull-vinyl
```
## API
### `vinyl.src(pattern, [options])`
Read `Vinyl` objects from the file system with patterns from [`pull-glob`](https://npmjs.com/pull-glob). You can use `vinyl.read` as an alias.
- `pattern`: A glob pattern resolved by `pull-glob`.
- `options` (`Object`): Options for reading.
It works as a [pull stream source](https://github.com/pull-stream/pull-stream#source-aka-readable):
```js
pull(
// Resolve glob into `Vinyl` objects.
vinyl.src('foo/**/*.js'),
// Transform `Vinyl` objects...
// Then write them:
vinyl.dest('bar')
)
```
### `vinyl.dest([base]])`
Write `Vinyl` objects at the `directory` base. You can use `vinyl.write` as an alias.
- `base` (`String`): The base directory for the `Vinyl` objects. Defaults to `file.base`.
```js
pull(
// Obtain `Vinyl` objects somehow, probably through reading:
vinyl.src('foo/**/*.js'),
// Transform them before you write them:
babel(), // Example stream.
// Write them to the given directory
vinyl.dest('out')
)
```
### `vinyl.map(name, [base])`
Maps data into vinyl files. Essentially [`vinyl-source-stream`](https://npmjs.com/vinyl-source-stream) as a pull-stream.
- `name` (`String`|`Function`): String of file's name, or a function to handle per item.
- `base` (`String`|`Function`): Optional base directory string, or a function to handle per item.
```js
pull(
// Pipe some data:
pull.values([ Buffer.from('hello world') ]),
// Map it to a file:
vinyl.map('bar.js', '/foo'),
// Use it
pull.drain(function (file) {
console.log(file)
})
)
```
## License
MIT © [Jamen Marz](https://github.com/jamen)