github.com/zkry/enry@v1.6.3/internal/code-generator/generator/linguist-commit.go (about)

     1  package generator
     2  
     3  import (
     4  	"bytes"
     5  	"text/template"
     6  )
     7  
     8  // Commit takes a commit and builds the source file from tmplPath. It complies with type File signature.
     9  func Commit(fileToParse, samplesDir, outPath, tmplPath, tmplName, commit string) error {
    10  	buf := &bytes.Buffer{}
    11  	t := template.Must(template.New(tmplName).ParseFiles(tmplPath))
    12  	if err := t.Execute(buf, commit); err != nil {
    13  		return err
    14  	}
    15  
    16  	return formatedWrite(outPath, buf.Bytes())
    17  }