UNPKG

976 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/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("ignoreFile", function (e) {
25 console.error("ignore file!", e)
26 })
27 .on("child", function (e) {
28 var p = e.path.substr(e.root.path.length)
29 var i = expected.indexOf(p)
30 if (i === -1) {
31 t.fail("unexpected file found", {file: p})
32 } else {
33 t.pass(p)
34 expected.splice(i, 1)
35 }
36 })
37 .on("close", function () {
38 t.notOk(expected.length, "all expected files should be seen")
39 t.end()
40 })
41})