Skip to content

Commit b51e40f

Browse files
committed
Require Node.js 12
1 parent 2e5d663 commit b51e40f

File tree

7 files changed

+30
-37
lines changed

7 files changed

+30
-37
lines changed

.github/funding.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13+
- 16
1314
- 14
1415
- 12
15-
- 10
16-
- 8
1716
steps:
1817
- uses: actions/checkout@v2
19-
- uses: actions/setup-node@v1
18+
- uses: actions/setup-node@v2
2019
with:
2120
node-version: ${{ matrix.node-version }}
2221
- run: npm install

index.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ const multimatch = require('multimatch');
55
const streamfilter = require('streamfilter');
66
const toAbsoluteGlob = require('to-absolute-glob');
77

8-
/**
9-
* @param {string | string[]|function(string):boolean} pattern function or glob pattern or array of glob patterns to filter files
10-
* @param {object} options see minimatch options, also root option for path resolving
11-
* @returns {Stream} Transform stream of Vinyl files
12-
*/
138
module.exports = (pattern, options = {}) => {
149
pattern = typeof pattern === 'string' ? [pattern] : pattern;
1510

@@ -25,8 +20,7 @@ module.exports = (pattern, options = {}) => {
2520
} else {
2621
const base = path.dirname(file.path);
2722
const patterns = pattern.map(pattern => {
28-
// Filename only matching glob
29-
// prepend full path
23+
// Filename only matching glob, prepend full path.
3024
if (!pattern.includes('/')) {
3125
if (pattern[0] === '!') {
3226
return '!' + path.resolve(base, pattern.slice(1));
@@ -37,8 +31,8 @@ module.exports = (pattern, options = {}) => {
3731

3832
pattern = toAbsoluteGlob(pattern, {cwd: file.cwd, root: options.root});
3933

40-
// Calling path.resolve after toAbsoluteGlob is required for removing .. from path
41-
// this is useful for ../A/B cases
34+
// Calling `path.resolve` after `toAbsoluteGlob` is required for removing `..` from path.
35+
// This is useful for `../A/B` cases.
4236
if (pattern[0] === '!') {
4337
return '!' + path.resolve(pattern.slice(1));
4438
}

license

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
3+
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
"description": "Filter files in a `vinyl` stream",
55
"license": "MIT",
66
"repository": "sindresorhus/gulp-filter",
7+
"funding": "https://github.com/sponsors/sindresorhus",
78
"author": {
89
"name": "Sindre Sorhus",
910
"email": "[email protected]",
10-
"url": "sindresorhus.com"
11+
"url": "https://sindresorhus.com"
1112
},
1213
"engines": {
13-
"node": ">=8"
14+
"node": ">=12"
1415
},
1516
"scripts": {
1617
"test": "xo && mocha"
@@ -31,15 +32,15 @@
3132
"vinyl"
3233
],
3334
"dependencies": {
34-
"multimatch": "^4.0.0",
35+
"multimatch": "^5.0.0",
3536
"plugin-error": "^1.0.1",
3637
"streamfilter": "^3.0.0",
3738
"to-absolute-glob": "^2.0.2"
3839
},
3940
"devDependencies": {
40-
"mocha": "^6.2.0",
41-
"vinyl": "^2.1.0",
42-
"xo": "^0.24.0"
41+
"mocha": "^8.3.2",
42+
"vinyl": "^2.2.1",
43+
"xo": "^0.39.1"
4344
},
4445
"peerDependencies": {
4546
"gulp": ">=4"

readme.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
55
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.
66

7-
87
## Install
98

109
```
1110
$ npm install --save-dev gulp-filter
1211
```
1312

14-
1513
## Usage
1614

1715
### Filter only
@@ -109,7 +107,6 @@ exports.default = () => {
109107
};
110108
```
111109

112-
113110
## API
114111

115112
### filter(pattern, options?)
@@ -138,14 +135,14 @@ Accepts [`minimatch` options](https://github.com/isaacs/minimatch#options).
138135

139136
##### restore
140137

141-
Type: `boolean`<br>
138+
Type: `boolean`\
142139
Default: `false`
143140

144141
Restore filtered files.
145142

146143
##### passthrough
147144

148-
Type: `boolean`<br>
145+
Type: `boolean`\
149146
Default: `true`
150147

151148
When set to `true`, filtered files are restored with a `stream.PassThrough`, otherwise, when set to `false`, filtered files are restored as a `stram.Readable`.

test.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const path = require('path');
44
const {strict: assert} = require('assert');
55
const Vinyl = require('vinyl');
6-
const filter = require('.');
6+
const filter = require('./index.js');
77

88
describe('filter()', () => {
99
it('should filter files', cb => {
@@ -318,12 +318,11 @@ describe('filter.restore', () => {
318318
// D /A/B/test.js
319319
// E /A/B/C/test.js
320320

321-
// matching behaviour:
322-
// 1) starting with / - absolute path matching
323-
// 2) starting with .. - relative path mapping, cwd prepended
324-
// 3) starting with just path, like abcd/<...> or **/**.js - relative path mapping, cwd prepended
325-
// same rules for !
326-
321+
// Matching behaviour:
322+
// 1) Starting with / - absolute path matching
323+
// 2) Starting with .. - relative path mapping, cwd prepended
324+
// 3) Starting with just path, like abcd/<...> or **/**.js - relative path mapping, cwd prepended
325+
// Same rules for `!`
327326
describe('path matching', () => {
328327
const testFilesPaths = [
329328
'/test.js',
@@ -333,6 +332,7 @@ describe('path matching', () => {
333332
'/A/B/C/test.js',
334333
'/A/B/C/d.js'
335334
];
335+
336336
const testFiles = testFilesPaths.map(path => new Vinyl({cwd: '/A/B', path}));
337337

338338
const testCases = [
@@ -429,19 +429,24 @@ describe('path matching', () => {
429429
];
430430

431431
for (const testCase of testCases) {
432-
it('Should ' + testCase.description, cb => {
432+
it(`Should ${testCase.description}`, cb => {
433433
const stream = filter(testCase.pattern);
434434

435-
testFiles.forEach(file => stream.write(file));
435+
for (const testFile of testFiles) {
436+
stream.write(testFile);
437+
}
436438

437439
const files = [];
440+
438441
stream.on('data', file => {
439442
files.push(file);
440443
});
444+
441445
stream.on('end', () => {
442-
assert.deepEqual(files.map(f => f.path), testCase.expectedFiles.map(f => f.path));
446+
assert.deepEqual(files.map(file => file.path), testCase.expectedFiles.map(file => file.path));
443447
cb();
444448
});
449+
445450
stream.end();
446451
});
447452
}

0 commit comments

Comments
 (0)