Socket
Socket
Sign inDemoInstall

gulp-filter

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-filter - npm Package Compare versions

Comparing version 6.0.0 to 7.0.0

30

index.js

@@ -6,2 +6,3 @@ 'use strict';

const streamfilter = require('streamfilter');
const toAbsoluteGlob = require('to-absolute-glob');

@@ -21,12 +22,25 @@ module.exports = (pattern, options = {}) => {

} else {
let relativePath = path.relative(file.cwd, file.path);
const base = path.dirname(file.path);
const patterns = pattern.map(pattern => {
// Filename only matching glob, prepend full path.
if (!pattern.includes('/')) {
if (pattern[0] === '!') {
return '!' + path.resolve(base, pattern.slice(1));
}
// If the path leaves the current working directory, then we need to
// resolve the absolute path so that the path can be properly matched
// by minimatch (via multimatch)
if (/^\.\.[\\/]/.test(relativePath)) {
relativePath = path.resolve(relativePath);
}
return path.resolve(base, pattern);
}
match = multimatch(relativePath, pattern, options).length > 0;
pattern = toAbsoluteGlob(pattern, {cwd: file.cwd, root: options.root});
// Calling `path.resolve` after `toAbsoluteGlob` is required for removing `..` from path.
// This is useful for `../A/B` cases.
if (pattern[0] === '!') {
return '!' + path.resolve(pattern.slice(1));
}
return path.resolve(pattern);
});
match = multimatch(path.resolve(file.cwd, file.path), patterns, options).length > 0;
}

@@ -33,0 +47,0 @@

{
"name": "gulp-filter",
"version": "6.0.0",
"version": "7.0.0",
"description": "Filter files in a `vinyl` stream",
"license": "MIT",
"repository": "sindresorhus/gulp-filter",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=8"
"node": ">=12"
},

@@ -34,11 +35,20 @@ "scripts": {

"dependencies": {
"multimatch": "^4.0.0",
"multimatch": "^5.0.0",
"plugin-error": "^1.0.1",
"streamfilter": "^3.0.0"
"streamfilter": "^3.0.0",
"to-absolute-glob": "^2.0.2"
},
"devDependencies": {
"mocha": "^6.1.4",
"vinyl": "^2.1.0",
"xo": "^0.24.0"
"mocha": "^8.3.2",
"vinyl": "^2.2.1",
"xo": "^0.39.1"
},
"peerDependencies": {
"gulp": ">=4"
},
"peerDependenciesMeta": {
"gulp": {
"optional": true
}
}
}

@@ -1,2 +0,2 @@

# gulp-filter [![Build Status](https://travis-ci.org/sindresorhus/gulp-filter.svg?branch=master)](https://travis-ci.org/sindresorhus/gulp-filter)
# gulp-filter

@@ -7,3 +7,2 @@ > Filter files in a [`vinyl`](https://github.com/gulpjs/vinyl) stream

## Install

@@ -15,3 +14,2 @@

## Usage

@@ -28,3 +26,3 @@

gulp.task('default', () => {
exports.default = () => {
// Create filter instance inside task function

@@ -39,3 +37,3 @@ const f = filter(['**', '!*src/vendor']);

.pipe(gulp.dest('dist'));
});
};
```

@@ -50,3 +48,3 @@

gulp.task('default', () => {
exports.default = () => {
// Create filter instance inside task function

@@ -63,3 +61,3 @@ const f = filter(['**', '!*src/vendor'], {restore: true});

.pipe(gulp.dest('dist'));
});
};
```

@@ -77,3 +75,3 @@

gulp.task('default', () => {
exports.default = () => {
const jsFilter = filter('**/*.js', {restore: true});

@@ -90,3 +88,3 @@ const lessFilter = filter('**/*.less', {restore: true});

.pipe(gulp.dest('out/'));
});
};
```

@@ -103,3 +101,3 @@

gulp.task('default', () => {
exports.default = () => {
const f = filter(['**', '!*src/vendor'], {restore: true, passthrough: false});

@@ -118,9 +116,8 @@

return stream;
});
};
```
## API
### filter(pattern, [options])
### filter(pattern, options?)

@@ -151,3 +148,3 @@ Returns a [transform stream](https://nodejs.org/api/stream.html#stream_class_stream_transform) with a [.restore](#optionsrestore) property.

Type: `boolean`<br>
Type: `boolean`\
Default: `false`

@@ -159,3 +156,3 @@

Type: `boolean`<br>
Type: `boolean`\
Default: `true`

@@ -162,0 +159,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc