Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ignore

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ignore - npm Package Compare versions

Comparing version 2.2.8 to 2.2.9

test/fixtures/.fakeignore

56

index.js

@@ -48,3 +48,3 @@ 'use strict';

// If false, ignore patterns with two globstars will be omitted
// - matchCase: {boolean=true} case sensitive.
// - matchCase: {boolean=} case sensitive.
// By default, git is case-insensitive

@@ -165,2 +165,27 @@ function Ignore (options){

var REPLACERS = [
// Escape metacharacters
// which is written down by users but means special for regular expressions.
// > There are 12 characters with special meanings:
// > - the backslash \,
// > - the caret ^,
// > - the dollar sign $,
// > - the period or dot .,
// > - the vertical bar or pipe symbol |,
// > - the question mark ?,
// > - the asterisk or star *,
// > - the plus sign +,
// > - the opening parenthesis (,
// > - the closing parenthesis ),
// > - and the opening square bracket [,
// > - the opening curly brace {,
// > These special characters are often called "metacharacters".
[
/[\\\^$.|?*+()\[{]/g,
function (match) {
return '\\' + match;
}
],
// leading slash

@@ -177,3 +202,4 @@ [

// > A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".
/\*\*\//,
// Notice that the '*'s have been replaced as '\\*'
/\\\*\\\*\//,

@@ -201,4 +227,7 @@ // '**/foo' <-> 'foo'

/(?:[^*\/])$/,
function (match1) {
return match1 + '(?=$|\\/)';
function (match) {
// 'js*' will not match 'a.js'
// 'js/' will not match 'a.js'
// 'js' will match 'a.js' and 'a.js/'
return match + '(?=$|\\/)';
}

@@ -209,3 +238,3 @@ ],

[
// there will be no leading '/' (which has been replaced by the first replacer)
// there will be no leading '/' (which has been replaced by the second replacer)
// If starts with '**', adding a '^' to the regular expression also works

@@ -220,7 +249,7 @@ /^(?=[^\^])/,

// '/**/'
/\/\*\*\//g,
/\/\\\*\\\*\//g,
// Zero, one or several directories
// should not use '*', or it will be replaced by the next replacer
'(?:\\/[^\\/]+){0,}\\/'
'(?:\\/[^\\/]+)*\\/'
],

@@ -230,6 +259,15 @@

[
/\*+/g,
// Never replace escaped '*'
// ignore rule '\*' will match the path '*'
/(^|[^\\]+)(\\\*)+/g,
// 'abc/*.js' matches 'abc/...js'
'[^\\/]*'
function (match, p1) {
return p1 + '[^\\/]*';
}
],
[
/\\\\\\/g,
'\\'
]

@@ -236,0 +274,0 @@ ];

2

package.json
{
"name": "ignore",
"version": "2.2.8",
"version": "2.2.9",
"description": "Ignore is a manager and filter for .gitignore rules.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,7 +0,3 @@

[![NPM version](https://badge.fury.io/js/ignore.png)](http://badge.fury.io/js/ignore)
[![Build Status](https://travis-ci.org/kaelzhang/node-ignore.png?branch=master)](https://travis-ci.org/kaelzhang/node-ignore)
[![Dependency Status](https://gemnasium.com/kaelzhang/node-ignore.png)](https://gemnasium.com/kaelzhang/node-ignore)
# ignore [![NPM version](https://badge.fury.io/js/ignore.png)](http://badge.fury.io/js/ignore) [![Build Status](https://travis-ci.org/kaelzhang/node-ignore.png?branch=master)](https://travis-ci.org/kaelzhang/node-ignore) [![Dependency Status](https://gemnasium.com/kaelzhang/node-ignore.png)](https://gemnasium.com/kaelzhang/node-ignore)
# ignore
`ignore` is a manager and filter according to the .gitignore [spec](http://git-scm.com/docs/gitignore).

@@ -55,6 +51,10 @@

2. `ignore` only contains utility methods to filter paths according to the specified ignore rules.
2. `ignore` only contains utility methods to filter paths according to the specified ignore rules, so
- `ignore` never try to find out ignore rules by traversing directories or fetching from git configurations.
- `ignore` don't cares about sub-modules of git projects.
3. Exactly according to [gitignore man page](http://git-scm.com/docs/gitignore), fixes some known matching issues of fstream-ignore, such as:
- '`/*.js`' should match '`a.js`', but not '`abc/a.js`'.
- '`/*.js`' should only match '`a.js`', but not '`abc/a.js`'.
- '`**/foo`' should match '`foo`' anywhere.

@@ -97,6 +97,45 @@

#### paths `Array`
#### paths `Array.<path>`
The array of paths to be filtered
The array of paths to be filtered.
*NOTICE* that each `path` here should be a relative path to the root of your repository. Suppose the dir structure is:
```
/path/to/your/repo
|-- a
| |-- a.js
|
|-- .b
|
|-- .c
|-- .DS_store
```
Then the `paths` might be like this:
```
[
'a/a.js'
'.b',
'.c/.DS_store'
]
```
Usually, you could use [`glob`](http://npmjs.org/package/glob) to fetch the structure of the current directory:
```
var glob = require('glob');
glob('**', function(err, files){
var filtered;
if ( err ) {
console.log(err);
} else {
filtered = ignore().addIgnoreFile('.gitignore').filter(files);
console.log(filtered);
}
});
```
## .createFilter()

@@ -103,0 +142,0 @@

@@ -251,3 +251,5 @@ 'use strict';

it(".addPattern(rule), chained", function(){
var ig = ignore().addPattern('abc').addPattern('!abc/b');
var ig = ignore()
.addPattern('abc')
.addPattern('!abc/b');

@@ -289,6 +291,7 @@ var filtered = [

it("will add patterns from the file", function(){
var result = ignore().addIgnoreFile(
var result = ignore()
.addIgnoreFile(
ignore.select([
'test/fixtures/.aignore',
'test/fixtures/.bignore'
'test/fixtures/.fakeignore'
])

@@ -307,1 +310,46 @@ ).filter([

describe("metacharacters of regular expression", function(){
it("should excape them", function(){
var result = ignore()
.addPattern([
'*.js',
'!\\*.js'
]).filter([
'*.js',
'abc.js'
]);
expect(result.sort()).to.deep.equal([
'*.js'
].sort());
});
});
describe("issue #2", function(){
it("question mark should not break all things", function(){
var result = ignore()
.addIgnoreFile('test/fixtures/.ignore-issue-2')
.filter([
'.project',
// remain
'abc/.project',
'.a.sw',
'.a.sw?',
'thumbs.db'
]);
expect(
// Sort the result
result.sort()
).to.deep.equal(
[
'abc/.project',
'.a.sw',
// 'thumbs.db'
].sort()
);
});
});
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