blob: 499195e08b401dcc3e156d2735be3fbf6425fd0a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
var Immutable = require('immutable');
var IgnoreMutable = require('ignore');
/*
Immutable version of node-ignore
*/
var Ignore = Immutable.Record({
ignore: new IgnoreMutable()
}, 'Ignore');
Ignore.prototype.getIgnore = function() {
return this.get('ignore');
};
/**
Test if a file is ignored by these rules
@param {String} filePath
@return {Boolean}
*/
Ignore.prototype.isFileIgnored = function(filename) {
var ignore = this.getIgnore();
return ignore.filter([filename]).length == 0;
};
/**
Add rules
@param {String}
@return {Ignore}
*/
Ignore.prototype.add = function(rule) {
var ignore = this.getIgnore();
var newIgnore = new IgnoreMutable();
newIgnore.add(ignore);
newIgnore.add(rule);
return this.set('ignore', newIgnore);
};
module.exports = Ignore;
|