Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

gulp-insert

rschmukler100.9kMIT0.5.0TypeScript support: definitely-typed

Append or Prepend a string with gulp

gulp, gulpplugin, append, insert, prepend

readme

gulp-insert

String manipulation library for gulp

Usage

npm install gulp-insert
var insert = require('gulp-insert');

Append

Appends a string onto the contents.

.pipe(insert.append('world')); // Appends 'world' to the contents of every file

Prepend

Prepends a string onto the contents.

.pipe(insert.prepend('Hello')); // Prepends 'Hello' to the contents of every file

Wrap

Wraps the contents with two strings.

.pipe(insert.wrap('Hello', 'World')); // prepends 'hello' and appends 'world' to the contents

Transform

Calls a function with the contents of the file.

.pipe(insert.transform(function(contents, file) {
  return contents.toUpperCase();
}));

Transform has access to the underlying vinyl file. The following code adds a '//' comment with the full file name before the actual content.

.pipe(insert.transform(function(contents, file) {

    var comment = '// local file: ' + file.path + '\n';
    return comment + contents;
}));

See https://github.com/wearefractal/vinyl for docmentation on the 'file' parameter.

changelog

0.5.0 / 2015-08-05

  • added file object as second parameter to transform hook

0.4.0 / 2014-06-28

  • Add function of file as arguments of appent/prepend/wrap

0.3.0 / 2014-04-06

  • Add support for streams (@nfroidure)
  • Add support for passing null files through

0.2.0 / 2014-02-02

  • Added wrap and transform methods

0.1.0 / 2014-01-17

  • Initial Release