feat(draw): make output file is optional
parent
cb1f44064f
commit
31f91ac0e5
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue