UNPKG

1.3 kBJavaScriptView Raw
1// ignore most things
2var IgnoreFile = require("../")
3
4// set the ignores just for this test
5var c = require("./common.js")
6c.ignores(
7 { ".ignore": ["*", "a", "c", "!a/b/c/.abc", "!/c/b/a/cba"]
8 , "a/.ignore": [ "!*", ".ignore" ] // unignore everything
9 , "a/a/.ignore": [ "*" ] // re-ignore everything
10 , "a/b/.ignore": [ "*", "!/c/.abc" ] // original unignore
11 , "a/c/.ignore": [ "*" ] // ignore everything again
12 , "c/b/a/.ignore": [ "!cba", "!.cba", "!/a{bc,cb}" ]
13 })
14
15// the only files we expect to see
16var 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
31require("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})