Skip to content

Commit

Permalink
Add example for CompileIgnoreLines
Browse files Browse the repository at this point in the history
  • Loading branch information
sabhiram committed Jan 12, 2015
1 parent 207652e commit a5992ef
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ignore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,19 @@ func TestCompileIgnoreLines_HandleLeadingSlashPath(test *testing.T) {
assert.Equal(test, true, object.IgnoresPath("hello.c"), "hello.c should be ignored")
assert.Equal(test, false, object.IgnoresPath("foo/hello.c"), "foo/hello.c should not be ignored")
}

func ExampleCompileIgnoreLines() {
ignoreObject, error := CompileIgnoreLines([]string{"node_modules", "*.out", "foo/*.c"}...)
if error != nil {
panic("Error when compiling ignore lines: " + error.Error())
}

fmt.Println(ignoreObject.IgnoresPath("node_modules/test/foo.js"))
fmt.Println(ignoreObject.IgnoresPath("node_modules2/test.out"))
fmt.Println(ignoreObject.IgnoresPath("test/foo.js"))

// Output:
// true
// true
// false
}

0 comments on commit a5992ef

Please sign in to comment.