gulp-filter
Advanced tools
Comparing version 5.1.0 to 6.0.0
15
index.js
@@ -7,5 +7,4 @@ 'use strict'; | ||
module.exports = (pattern, options) => { | ||
module.exports = (pattern, options = {}) => { | ||
pattern = typeof pattern === 'string' ? [pattern] : pattern; | ||
options = options || {}; | ||
@@ -16,3 +15,3 @@ if (!Array.isArray(pattern) && typeof pattern !== 'function') { | ||
return streamfilter((file, enc, cb) => { | ||
return streamfilter((file, encoding, callback) => { | ||
let match; | ||
@@ -23,3 +22,3 @@ | ||
} else { | ||
let relPath = path.relative(file.cwd, file.path); | ||
let relativePath = path.relative(file.cwd, file.path); | ||
@@ -29,10 +28,10 @@ // If the path leaves the current working directory, then we need to | ||
// by minimatch (via multimatch) | ||
if (/^\.\.[\\/]/.test(relPath)) { | ||
relPath = path.resolve(relPath); | ||
if (/^\.\.[\\/]/.test(relativePath)) { | ||
relativePath = path.resolve(relativePath); | ||
} | ||
match = multimatch(relPath, pattern, options).length > 0; | ||
match = multimatch(relativePath, pattern, options).length > 0; | ||
} | ||
cb(!match); | ||
callback(!match); | ||
}, { | ||
@@ -39,0 +38,0 @@ objectMode: true, |
{ | ||
"name": "gulp-filter", | ||
"version": "5.1.0", | ||
"description": "Filter files in a Vinyl stream", | ||
"license": "MIT", | ||
"repository": "sindresorhus/gulp-filter", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && mocha" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"gulpplugin", | ||
"filter", | ||
"ignore", | ||
"file", | ||
"files", | ||
"match", | ||
"minimatch", | ||
"glob", | ||
"globbing" | ||
], | ||
"dependencies": { | ||
"multimatch": "^2.0.0", | ||
"plugin-error": "^0.1.2", | ||
"streamfilter": "^1.0.5" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*", | ||
"vinyl": "^2.1.0", | ||
"xo": "*" | ||
} | ||
"name": "gulp-filter", | ||
"version": "6.0.0", | ||
"description": "Filter files in a `vinyl` stream", | ||
"license": "MIT", | ||
"repository": "sindresorhus/gulp-filter", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && mocha" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"gulpplugin", | ||
"filter", | ||
"ignore", | ||
"file", | ||
"files", | ||
"match", | ||
"minimatch", | ||
"glob", | ||
"globbing", | ||
"vinyl" | ||
], | ||
"dependencies": { | ||
"multimatch": "^4.0.0", | ||
"plugin-error": "^1.0.1", | ||
"streamfilter": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^6.1.4", | ||
"vinyl": "^2.1.0", | ||
"xo": "^0.24.0" | ||
} | ||
} |
# gulp-filter [![Build Status](https://travis-ci.org/sindresorhus/gulp-filter.svg?branch=master)](https://travis-ci.org/sindresorhus/gulp-filter) | ||
> Filter files in a [Vinyl](https://github.com/gulpjs/vinyl) stream | ||
> Filter files in a [`vinyl`](https://github.com/gulpjs/vinyl) stream | ||
Enables you to work on a subset of the original files by filtering them using glob patterns. When you're done and want all the original files back you just use the `restore` stream. | ||
Enables you to work on a subset of the original files by filtering them using glob patterns. When you're done and want all the original files back, you just use the `restore` stream. | ||
@@ -117,11 +117,11 @@ | ||
Returns a [transform stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) with a [.restore](#optionsrestore) property. | ||
Returns a [transform stream](https://nodejs.org/api/stream.html#stream_class_stream_transform) with a [.restore](#optionsrestore) property. | ||
#### pattern | ||
Type: `string` `Array` `Function` | ||
Type: `string | string[] | Function` | ||
Accepts a string/array with globbing patterns which are run through [multimatch](https://github.com/sindresorhus/multimatch). | ||
If you supply a function, you'll get a [vinyl file object](https://github.com/wearefractal/vinyl#file) as the first argument and you're expected to return a boolean of whether to include the file: | ||
If you supply a function, you'll get a [`vinyl` file object](https://github.com/wearefractal/vinyl#file) as the first argument and you're expected to return a boolean of whether to include the file: | ||
@@ -134,7 +134,7 @@ ```js | ||
Type: `Object` | ||
Type: `object` | ||
Accepts [minimatch options](https://github.com/isaacs/minimatch#options). | ||
Accepts [`minimatch` options](https://github.com/isaacs/minimatch#options). | ||
*Note:* Set `dot: true` if you need to match files prefixed with a dot (e.g. `.gitignore`). | ||
*Note:* Set `dot: true` if you need to match files prefixed with a dot, for example, `.gitignore`. | ||
@@ -156,6 +156,1 @@ ##### restore | ||
When the stream is a `stream.Readable`, it ends by itself, but when it's `stream.PassThrough`, you are responsible of ending the stream. | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6996
31
154
+ Added@types/minimatch@3.0.5(transitive)
+ Addedansi-colors@1.1.0(transitive)
+ Addedarr-diff@4.0.0(transitive)
+ Addedarr-union@3.1.0(transitive)
+ Addedarray-differ@3.0.0(transitive)
+ Addedarray-union@2.1.0(transitive)
+ Addedarrify@2.0.1(transitive)
+ Addedassign-symbols@1.0.0(transitive)
+ Addedextend-shallow@3.0.2(transitive)
+ Addedis-extendable@1.0.1(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedisobject@3.0.1(transitive)
+ Addedmultimatch@4.0.0(transitive)
+ Addedplugin-error@1.0.1(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstreamfilter@3.0.0(transitive)
+ Addedstring_decoder@1.3.0(transitive)
- Removedansi-cyan@0.1.1(transitive)
- Removedansi-red@0.1.1(transitive)
- Removedarr-diff@1.1.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@2.1.0(transitive)
- Removedarray-differ@1.0.0(transitive)
- Removedarray-slice@0.2.3(transitive)
- Removedarray-union@1.0.2(transitive)
- Removedarray-uniq@1.0.3(transitive)
- Removedarrify@1.0.1(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedextend-shallow@1.1.4(transitive)
- Removedisarray@1.0.0(transitive)
- Removedkind-of@1.1.0(transitive)
- Removedmultimatch@2.1.0(transitive)
- Removedplugin-error@0.1.2(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedstreamfilter@1.0.7(transitive)
- Removedstring_decoder@1.1.1(transitive)
Updatedmultimatch@^4.0.0
Updatedplugin-error@^1.0.1
Updatedstreamfilter@^3.0.0