feat(draw): make output file is optional

main
sudo pacman -Syu 2023-07-23 16:04:10 +07:00
parent cb1f44064f
commit 31f91ac0e5
1 changed files with 8 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"fmt"
"log"
"os"
)
@ -17,11 +18,6 @@ func main() {
log.Fatalln("ENV QMK_KEYMAP empty")
}
filenameOut := os.Getenv("OUT")
if filenameOut == "" {
log.Fatalln("ENV OUT empty")
}
bytesInfo, err := os.ReadFile(filenameInfo)
if err != nil {
log.Fatalln("Failed to read file", filenameInfo, err)
@ -46,8 +42,13 @@ func main() {
qmkInfo.Layouts,
qmkKeymap,
)
fmt.Println(result)
if err := os.WriteFile(filenameOut, []byte(result), 0o644); err != nil {
log.Fatalln("Failed to write file", filenameOut, err)
// Optional
filenameOut := os.Getenv("OUT")
if filenameOut != "" {
if err := os.WriteFile(filenameOut, []byte(result), 0o644); err != nil {
log.Fatalln("Failed to write file", filenameOut, err)
}
}
}