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'));
Prepend
Prepends a string onto the contents.
.pipe(insert.prepend('Hello'));
Wrap
Wraps the contents with two strings.
.pipe(insert.wrap('Hello', 'World'));
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.