feat: add support for cmake files

Co-authored-by: Sergii Baitala <sbaitala@gmail.com>
This commit is contained in:
Will Norris
2021-08-10 09:50:06 -07:00
parent 90da58c801
commit 2b44b36759
2 changed files with 15 additions and 0 deletions

View File

@@ -306,6 +306,11 @@ func licenseHeader(path string, tmpl *template.Template, data licenseData) ([]by
lic, err = executeTemplate(tmpl, data, "", "// ", "")
case ".ml", ".mli", ".mll", ".mly":
lic, err = executeTemplate(tmpl, data, "(**", " ", "*)")
default:
// handle various cmake files
if base == "cmakelists.txt" || strings.HasSuffix(base, ".cmake.in") || strings.HasSuffix(base, ".cmake") {
lic, err = executeTemplate(tmpl, data, "", "# ", "")
}
}
return lic, err
}

View File

@@ -339,6 +339,16 @@ func TestLicenseHeader(t *testing.T) {
[]string{"f.ml", "f.mli", "f.mll", "f.mly"},
"(**\n HYS\n*)\n\n",
},
{
[]string{"cmakelists.txt", "f.cmake", "f.cmake.in"},
"# HYS\n\n",
},
// ensure matches are case insenstive
{
[]string{"F.PY", "DoCkErFiLe"},
"# HYS\n\n",
},
}
for _, tt := range tests {