gulp-insert
Append or Prepend a string with gulp
Last updated 5 years ago by rschmukler .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gulp-insert 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 0.5.0                                ...           latest (5 years ago)

5 Versions

  • 0.5.0                                ...           5 years ago
  • 0.4.0                                ...           6 years ago
  • 0.3.0                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Downloads
Today 220
This Week 447
This Month 1,228
Last Day 227
Last Week 1,271
Last Month 5,582
Dependencies (2)
Dev Dependencies (3)
Dependents (207)

Copyright 2014 - 2016 © taobao.org |