UNPKG

900 BJavaScriptView Raw
1// ignore most things
2var IgnoreFile = require("../")
3
4// set the ignores just for this test
5var c = require("./common.js")
6c.ignores({ ".ignore": ["*", "a", "c", "!a/b/c/.abc", "!/c/b/a/cba"] })
7
8// the only files we expect to see
9var expected =
10 [ "/a/b/c/.abc"
11 , "/a"
12 , "/a/b"
13 , "/a/b/c"
14 , "/c/b/a/cba"
15 , "/c"
16 , "/c/b"
17 , "/c/b/a" ]
18
19require("tap").test("basic ignore rules", function (t) {
20 t.pass("start")
21
22 IgnoreFile({ path: __dirname + "/fixtures"
23 , ignoreFiles: [".ignore"] })
24 .on("child", function (e) {
25 var p = e.path.substr(e.root.path.length)
26 var i = expected.indexOf(p)
27 if (i === -1) {
28 t.fail("unexpected file found", {f: p})
29 } else {
30 t.pass(p)
31 expected.splice(i, 1)
32 }
33 })
34 .on("close", function () {
35 t.notOk(expected.length, "all expected files should be seen")
36 t.end()
37 })
38})