feat(draw): make output file is optional
parent
cb1f44064f
commit
31f91ac0e5
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
@ -17,11 +18,6 @@ func main() {
|
||||||
log.Fatalln("ENV QMK_KEYMAP empty")
|
log.Fatalln("ENV QMK_KEYMAP empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
filenameOut := os.Getenv("OUT")
|
|
||||||
if filenameOut == "" {
|
|
||||||
log.Fatalln("ENV OUT empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
bytesInfo, err := os.ReadFile(filenameInfo)
|
bytesInfo, err := os.ReadFile(filenameInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("Failed to read file", filenameInfo, err)
|
log.Fatalln("Failed to read file", filenameInfo, err)
|
||||||
|
@ -46,8 +42,13 @@ func main() {
|
||||||
qmkInfo.Layouts,
|
qmkInfo.Layouts,
|
||||||
qmkKeymap,
|
qmkKeymap,
|
||||||
)
|
)
|
||||||
|
fmt.Println(result)
|
||||||
|
|
||||||
|
// Optional
|
||||||
|
filenameOut := os.Getenv("OUT")
|
||||||
|
if filenameOut != "" {
|
||||||
if err := os.WriteFile(filenameOut, []byte(result), 0o644); err != nil {
|
if err := os.WriteFile(filenameOut, []byte(result), 0o644); err != nil {
|
||||||
log.Fatalln("Failed to write file", filenameOut, err)
|
log.Fatalln("Failed to write file", filenameOut, err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue