1 | 'use strict';
|
2 | var utils = require('../utils');
|
3 | var add = require('./add');
|
4 | var parse = require('./parse');
|
5 |
|
6 |
|
7 | var rules = { ignore: [], watch: [] };
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | function load(filename, callback) {
|
18 | parse(filename, function (err, result) {
|
19 | if (err) {
|
20 |
|
21 | utils.log.error(err);
|
22 | callback(err);
|
23 | }
|
24 |
|
25 | if (result.raw) {
|
26 | result.raw.forEach(add.bind(null, rules, 'ignore'));
|
27 | } else {
|
28 | result.ignore.forEach(add.bind(null, rules, 'ignore'));
|
29 | result.watch.forEach(add.bind(null, rules, 'watch'));
|
30 | }
|
31 |
|
32 | callback(null, rules);
|
33 | });
|
34 | }
|
35 |
|
36 | module.exports = {
|
37 | reset: function () {
|
38 | rules.ignore.length = rules.watch.length = 0;
|
39 | delete rules.ignore.re;
|
40 | delete rules.watch.re;
|
41 | },
|
42 | load: load,
|
43 | ignore: {
|
44 | test: add.bind(null, rules, 'ignore'),
|
45 | add: add.bind(null, rules, 'ignore'),
|
46 | },
|
47 | watch: {
|
48 | test: add.bind(null, rules, 'watch'),
|
49 | add: add.bind(null, rules, 'watch'),
|
50 | },
|
51 | add: add.bind(null, rules),
|
52 | rules: rules,
|
53 | }; |
\ | No newline at end of file |