Skip to content

Commit 2b44b36

Browse files
willnorrissrgbtl
andcommitted
feat: add support for cmake files
Co-authored-by: Sergii Baitala <[email protected]>
1 parent 90da58c commit 2b44b36

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@ func licenseHeader(path string, tmpl *template.Template, data licenseData) ([]by
306306
lic, err = executeTemplate(tmpl, data, "", "// ", "")
307307
case ".ml", ".mli", ".mll", ".mly":
308308
lic, err = executeTemplate(tmpl, data, "(**", " ", "*)")
309+
default:
310+
// handle various cmake files
311+
if base == "cmakelists.txt" || strings.HasSuffix(base, ".cmake.in") || strings.HasSuffix(base, ".cmake") {
312+
lic, err = executeTemplate(tmpl, data, "", "# ", "")
313+
}
309314
}
310315
return lic, err
311316
}

main_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,16 @@ func TestLicenseHeader(t *testing.T) {
339339
[]string{"f.ml", "f.mli", "f.mll", "f.mly"},
340340
"(**\n HYS\n*)\n\n",
341341
},
342+
{
343+
[]string{"cmakelists.txt", "f.cmake", "f.cmake.in"},
344+
"# HYS\n\n",
345+
},
346+
347+
// ensure matches are case insenstive
348+
{
349+
[]string{"F.PY", "DoCkErFiLe"},
350+
"# HYS\n\n",
351+
},
342352
}
343353

344354
for _, tt := range tests {

0 commit comments

Comments
 (0)