1.0.0 • Published 5 years ago

vinyl-replace v1.0.0

Weekly downloads
1
License
BSD-3-Clause
Repository
-
Last release
5 years ago

vinyl-replace

A Vinyl plugin to replace file contents.

API

vinylReplace (transform)

Create a transform stream that applies transform to each passed file vinyl. Internally, a file vinyl is one with its contents property set to either a Buffer or Readable stream object. Any other vinyl is passed through as is.

The transform function

The transform function is any callable object accepting as input a string (the vinyl's content) and returning a possibly new version of it, that will be replaced as the new content of the vinyl.

Example

const { src, dest } = require('gulp');
const vinylReplace = require('vinyl-replace');

function myTask () {
  return src('*.txt')
    .pipe(vinylReplace((input) => {
      return input.replace('something', 'everything');
    }))
    .pipe(dest('dist/'));
}

License

This project is distributed under the BSD 3 Clause license (BSD-3-Clause). Please see the LICENSE file.