README
vinyl-properties
Collect vinyl file properties in a stream
const gulp = require('gulp');
const vinylProperties = require('vinyl-properties');
gulp.task('default', () => {
const props = vinylProperties('relative');
return gulp.src(['foo.js', 'bar.js'])
.pipe(props)
.pipe(gulp.dest('dist'))
.on('finish', () => {
props.relative; //=> ['foo.js', 'bar.js']
});
});
Installation
npm install vinyl-properties
API
const vinylProperties = require('vinyl-properties');
vinylProperties(properties)
properties: String
or Array
of String
(the names of properties you want to collect)
Return: Object
(stream.Transform)
Every time the stream reads a vinyl file object, it pushes the value of vinyl properties you specified to the stream's properties in the same names, and pushes all of them to the files
property.
gulp.task('default', () => {
const props = vinylProperties(['path', 'contents']);
return gulp.src('*.txt')
.pipe(props)
.pipe(gulp.dest('dist'))
.on('finish', () => {
props.path; //=> ['file0.txt', 'file1.txt', ...]
props.contents; //=> [<Buffer ... >, <Buffer ... >, ...]
props.files; /*=>
[
{
path: 'file0.txt',
contents: <Buffer ... >
},
{
path: 'file1.txt',
contents: <Buffer ... >
},
...
]
*/
});
});
License
Copyright (c) 2015 Shinnosuke Watanabe
Licensed under the MIT License.