Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikehazell/gulp-inject-string
Inject snippets in build
https://github.com/mikehazell/gulp-inject-string
Last synced: 16 days ago
JSON representation
Inject snippets in build
- Host: GitHub
- URL: https://github.com/mikehazell/gulp-inject-string
- Owner: mikehazell
- License: mit
- Created: 2014-07-29T21:37:44.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T18:15:48.000Z (almost 2 years ago)
- Last Synced: 2024-10-14T05:07:49.884Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 529 KB
- Stars: 40
- Watchers: 5
- Forks: 12
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-inject-string
[![Build Status](https://travis-ci.org/mikehazell/gulp-inject-string.svg?branch=master)](https://travis-ci.org/mikehazell/gulp-inject-string)
[![NPM version](https://badge.fury.io/js/gulp-inject-string.svg)](http://badge.fury.io/js/gulp-inject-string)Inject snippets in build
## Methods
```js
append(str) // Appends the string
prepend(str) // Prepends the string
wrap(start, end) // Wraps file contents in between *start* and *end*
before(search, str) // Inserts the string before the first occurence of *search*
after(search, str) // Inserts the string after the first occurence of *search*
beforeEach(search, str) // Inserts the string before each occurence of *search*
afterEach(search, str) // Inserts the string after each occurence of *search*
replace(search, str) // Replaces each occurence of *search* with *str*
```## Examples
See [examples/build](https://github.com/mikehazell/gulp-inject-string/tree/master/examples/build) for output.
```js
var gulp = require('gulp'),
rename = require('gulp-rename'),
inject = require('gulp-inject-string');gulp.task('inject:append', function(){
gulp.src('src/example.html')
.pipe(inject.append('\n'))
.pipe(rename('append.html'))
.pipe(gulp.dest('build'));
});gulp.task('inject:prepend', function(){
gulp.src('src/example.html')
.pipe(inject.prepend('\n'))
.pipe(rename('prepend.html'))
.pipe(gulp.dest('build'));
});gulp.task('inject:wrap', function(){
gulp.src('src/example.html')
.pipe(inject.wrap('\n', ''))
.pipe(rename('wrap.html'))
.pipe(gulp.dest('build'));
});gulp.task('inject:before', function(){
gulp.src('src/example.html')
.pipe(inject.before('\n'))
.pipe(rename('before.html'))
.pipe(gulp.dest('build'));
});gulp.task('inject:after', function(){
gulp.src('src/example.html')
.pipe(inject.after('', '\n\n'))
.pipe(rename('after.html'))
.pipe(gulp.dest('build'));
});gulp.task('inject:beforeEach', function(){
gulp.src('src/example.html')
.pipe(inject.beforeEach('