Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rschmukler/gulp-insert
string mutation library for gulp
https://github.com/rschmukler/gulp-insert
Last synced: 5 days ago
JSON representation
string mutation library for gulp
- Host: GitHub
- URL: https://github.com/rschmukler/gulp-insert
- Owner: rschmukler
- License: mit
- Created: 2014-01-18T01:51:41.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2020-10-12T21:32:29.000Z (about 4 years ago)
- Last Synced: 2024-11-03T17:40:29.221Z (10 days ago)
- Language: JavaScript
- Homepage:
- Size: 14.6 KB
- Stars: 61
- Watchers: 5
- Forks: 6
- Open Issues: 8
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-insert
String manipulation library for gulp
## Usage
```
npm install gulp-insert
``````js
var insert = require('gulp-insert');
```## Append
Appends a string onto the contents.
```js
.pipe(insert.append('world')); // Appends 'world' to the contents of every file
```## Prepend
Prepends a string onto the contents.
```js
.pipe(insert.prepend('Hello')); // Prepends 'Hello' to the contents of every file
```
## WrapWraps the contents with two strings.
```js
.pipe(insert.wrap('Hello', 'World')); // prepends 'hello' and appends 'world' to the contents
```## Transform
Calls a function with the contents of the file.
```js
.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.
```js
.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.