1 |
|
2 | var IgnoreFile = require("../")
|
3 |
|
4 |
|
5 | var c = require("./common.js")
|
6 | c.ignores(
|
7 | { ".ignore": ["*", "a", "c", "!a/b/c/.abc", "!/c/b/a/cba"]
|
8 | , "a/.ignore": [ "!*", ".ignore" ]
|
9 | , "a/a/.ignore": [ "*" ]
|
10 | , "a/b/.ignore": [ "*", "!/c/.abc" ]
|
11 | , "a/c/.ignore": [ "*" ]
|
12 | , "c/b/a/.ignore": [ "!cba", "!.cba", "!/a{bc,cb}" ]
|
13 | })
|
14 |
|
15 |
|
16 | var expected =
|
17 | [ "/a"
|
18 | , "/a/a"
|
19 | , "/a/b"
|
20 | , "/a/b/c"
|
21 | , "/a/b/c/.abc"
|
22 | , "/a/c"
|
23 | , "/c"
|
24 | , "/c/b"
|
25 | , "/c/b/a"
|
26 | , "/c/b/a/cba"
|
27 | , "/c/b/a/.cba"
|
28 | , "/c/b/a/abc"
|
29 | , "/c/b/a/acb" ]
|
30 |
|
31 | require("tap").test("basic ignore rules", function (t) {
|
32 | t.pass("start")
|
33 |
|
34 | IgnoreFile({ path: __dirname + "/fixtures"
|
35 | , ignoreFiles: [".ignore"] })
|
36 | .on("child", function (e) {
|
37 | var p = e.path.substr(e.root.path.length)
|
38 | var i = expected.indexOf(p)
|
39 | if (i === -1) {
|
40 | console.log("not ok "+p)
|
41 | t.fail("unexpected file found", {found: p})
|
42 | } else {
|
43 | t.pass(p)
|
44 | expected.splice(i, 1)
|
45 | }
|
46 | })
|
47 | .on("close", function () {
|
48 | t.deepEqual(expected, [], "all expected files should be seen")
|
49 | t.end()
|
50 | })
|
51 | })
|