feat: autoformatter

This commit is contained in:
2025-03-08 23:51:17 +07:00
parent 9fd83b52e6
commit 0f5d61de48
7 changed files with 157 additions and 79 deletions

26
utils/prettier.go Normal file
View File

@@ -0,0 +1,26 @@
package utils
import (
"fmt"
"log"
"os/exec"
)
func FormatFilesWithPrettier(files []string) error {
if len(files) == 0 {
return fmt.Errorf("empty file list")
}
args := append([]string{"prettier", "--write"}, files...)
cmd := exec.Command("npx", args...)
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("formatter error: %s\nOutput: %s", err, output)
}
log.Println("prettier was applied")
return nil
}