2016-11-03 01:33:53 +01:00
< p align = "center" >
< a href = "http://gulpjs.com" >
< img height = "257" width = "114" src = "https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png" >
< / a >
< / p >
2016-10-10 03:43:44 +02:00
2016-11-03 01:33:53 +01:00
# glob-stream
2016-10-10 03:43:44 +02:00
2016-11-03 01:33:53 +01:00
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
2016-10-10 03:43:44 +02:00
2016-11-03 01:33:53 +01:00
A wrapper around [node-glob][node-glob-url] to make it streamy.
2016-10-10 03:43:44 +02:00
## Usage
```javascript
var gs = require('glob-stream');
2016-11-03 01:33:53 +01:00
var stream = gs.create('./files/**/*.coffee', { /* options */ });
2016-10-10 03:43:44 +02:00
stream.on('data', function(file){
// file has path, base, and cwd attrs
});
```
You can pass any combination of globs. One caveat is that you can not only pass a glob negation, you must give it at least one positive glob so it knows where to start. All given must match for the file to be returned.
2016-11-03 01:33:53 +01:00
## API
### create(globs, options)
Returns a stream for multiple globs or filters.
### createStream(positiveGlob, negativeGlobs, options)
Returns a stream for a single glob or filter.
2016-10-10 03:43:44 +02:00
### Options
- cwd
- Default is `process.cwd()`
- base
2016-11-03 01:33:53 +01:00
- Default is everything before a glob starts (see [glob-parent][glob-parent-url])
2016-10-10 03:43:44 +02:00
- cwdbase
- Default is `false`
- When true it is the same as saying opt.base = opt.cwd
2016-11-03 01:33:53 +01:00
- allowEmpty
- Default is `false`
- If true, won't emit an error when a glob pointing at a single file fails to match
- Any through2 related options are documented in [through2][through2-url]
2016-10-10 03:43:44 +02:00
2016-11-03 01:33:53 +01:00
This argument is passed directly to [node-glob][node-glob-url] so check there for more options
2016-10-10 03:43:44 +02:00
2016-11-03 01:33:53 +01:00
### Glob
2016-10-10 03:43:44 +02:00
2016-11-03 01:33:53 +01:00
```js
var stream = gs.create(['./**/*.js', '!./node_modules/**/*']);
```
Globs are executed in order, so negations should follow positive globs. For example:
```js
gulp.src(['!b*.js', '*.js'])
```
would not exclude any files, but this would
```js
gulp.src(['*.js', '!b*.js'])
2016-10-10 03:43:44 +02:00
```
2016-11-03 01:33:53 +01:00
## Related
- [globby][globby-url] - Non-streaming `glob` wrapper with support for multiple patterns.
## License
MIT
[globby-url]: https://github.com/sindresorhus/globby
[through2-url]: https://github.com/rvagg/through2
[node-glob-url]: https://github.com/isaacs/node-glob
[glob-parent-url]: https://github.com/es128/glob-parent
2016-10-10 03:43:44 +02:00
2016-11-03 01:33:53 +01:00
[downloads-image]: http://img.shields.io/npm/dm/glob-stream.svg
[npm-url]: https://www.npmjs.com/package/glob-stream
[npm-image]: https://badge.fury.io/js/glob-stream.svg
2016-10-10 03:43:44 +02:00
2016-11-03 01:33:53 +01:00
[travis-url]: https://travis-ci.org/gulpjs/glob-stream
[travis-image]: https://travis-ci.org/gulpjs/glob-stream.svg?branch=master
2016-10-10 03:43:44 +02:00
2016-11-03 01:33:53 +01:00
[coveralls-url]: https://coveralls.io/r/gulpjs/glob-stream
[coveralls-image]: https://coveralls.io/repos/gulpjs/glob-stream/badge.svg
2016-10-10 03:43:44 +02:00
2016-11-03 01:33:53 +01:00
[gitter-url]: https://gitter.im/gulpjs/gulp
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.png