Neat Paraskavedekatriaphobia's Meaning

npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

vinyl-properties

2.0.0 • Public • Published

vinyl-properties

NPM version Build Status Coverage Status devDependency Status

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

Use npm.

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.

install

npm i vinyl-properties

Downloadsweekly downloads

9

version

2.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability