File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 "fmt"
55 "io"
66 "path/filepath"
7+ "strings"
78 "text/template"
89
910 "github.com/fmenezes/codeowners"
@@ -38,7 +39,10 @@ func run(wr io.Writer, opt options) exitCode {
3839 format = opt .format
3940 }
4041 format = fmt .Sprintf ("%s\n " , format )
41- tpl , err := template .New ("main" ).Parse (format )
42+ tpl , err := template .New ("main" ).Funcs (template.FuncMap {
43+ "ToLower" : strings .ToLower ,
44+ "ToUpper" : strings .ToUpper ,
45+ }).Parse (format )
4246 if err != nil {
4347 fmt .Fprintf (wr , "Unexpected error when parsing format: %v" , err )
4448 return unexpectedErrorCode
Original file line number Diff line number Diff line change @@ -50,6 +50,14 @@ func TestCustomFormat(t *testing.T) {
5050` )
5151}
5252
53+ func TestCustomFormatFunc (t * testing.T ) {
54+ assert (t , options {
55+ directory : "../../test/data/noowners" ,
56+ format : "{{ToLower .Position.FilePath}}" ,
57+ }, errorCode , `codeowners
58+ ` )
59+ }
60+
5361func TestInvalidFormatParse (t * testing.T ) {
5462 assertCode (t , options {
5563 directory : "../../test/data/noowners" ,
You can’t perform that action at this time.
0 commit comments