Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/callumacrae/gulp-contains
:hand: Throws an error or calls a callback if a given string is found in a file.
https://github.com/callumacrae/gulp-contains
Last synced: 2 months ago
JSON representation
:hand: Throws an error or calls a callback if a given string is found in a file.
- Host: GitHub
- URL: https://github.com/callumacrae/gulp-contains
- Owner: callumacrae
- License: mit
- Created: 2015-02-16T18:03:32.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-06-13T09:21:35.000Z (over 5 years ago)
- Last Synced: 2024-10-19T21:26:43.498Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 5
- Watchers: 3
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gulp-contains [![Build Status](https://travis-ci.org/callumacrae/gulp-contains.svg?branch=master)](https://travis-ci.org/callumacrae/gulp-contains)
Throws an error or calls a callback if a given string is found in a file.
Useful for dumb quality checking.
## Install
```
$ npm install --save-dev gulp-contains
```## Usage
The following code will throw an error if "../node_modules" is found in any
Sass or SCSS file.```js
var gulp = require('gulp');
var contains = require('gulp-contains');gulp.task('default', function () {
gulp.src('./src/**/*.{sass, scss}')
.pipe(contains('../node_modules'));
});
```The contains function accepts a string, a regular expression or an array of either (any of
which, when matched, will cause an error to be thrown).You can also specify a callback function, in which you can handle the error
yourself or choose to completely ignore it:```js
var gulp = require('gulp');
var contains = require('gulp-contains');gulp.task('default', function () {
gulp.src('./src/**/*.{sass, scss}')
.pipe(contains({
search: '../node_modules',
onFound: function (string, file, cb) {
// string is the string that was found
// file is the vinyl file object
// cb is the through2 callback// return false to continue the stream
}
}));
});
```## License
Released under the MIT license.