gulp-inject-self
v1.0.0
Published
A gulp plugin that injects self stream to a destination file.
Downloads
1
Maintainers
Readme
gulp-inject-self
A Gulp that injects self stream to a destination file.
for stream.txt:
my own file
and for dest.txt:
dest insert here dest
the code
var injectSelf = require('gulp-inject-self'); gulp.task('inject', function(){ return gulp.src('stream.txt') .pipe(injectSelf('dest.txt', /insert here/)) .pipe(gulp.dest('.')); }
outputs stream.txt with the content:
dest my own file dest
and the code
var injectSelf = require('gulp-inject-self'); gulp.task('inject', function(){ return gulp.src('stream.txt') .pipe(injectSelf('dest.txt', /insert here/, { replaceWith: function(fileContent){ return '$&\n' + fileContent; //the string being replaced, new line, file content from the stream } })) .pipe(gulp.dest('.')); }
outputs stream.txt with the content:
dest insert here my own file dest
Getting Started
This plugin requires Gulp ~3.5.5
If you haven't used Gulp before, be sure to check out the Getting Started guide, as it explains how to create a Gulpfile as well as install and use Gulp plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install gulp-inject-self --save-dev
Once the plugin has been installed, it should be required inside your Gulpfile:
var injectSelf = require('gulp-inject-self');
Options
options.replaceWith
Type: Function
Default value: function(contents){ return contents; }
Preprocessing the contents of file from the gulp stream when replace is applied on the target file.
options.skipBinary
Type: Boolean
Default value: false
Should binary files be skipped.
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Gulp.
Release History
- 0.0.1 - initial release.
- 1.0.0 - added tests, fixed bugs.