hopefully eliminate the weird case of cron and githubactions calling nak with an empty stdin and causing it to do nothing.

closes https://github.com/fiatjaf/nak/issues/90
This commit is contained in:
fiatjaf
2026-01-16 16:08:29 -03:00
parent acd6227dd0
commit c6da13649d
2 changed files with 10 additions and 3 deletions

View File

@@ -155,6 +155,7 @@ example:
os.Exit(3)
}
}
kr, sec, err := gatherKeyerFromArguments(ctx, c)
if err != nil {
return err

View File

@@ -46,8 +46,14 @@ var (
)
func isPiped() bool {
stat, _ := os.Stdin.Stat()
return stat.Mode()&os.ModeCharDevice == 0
stat, err := os.Stdin.Stat()
if err != nil {
panic(err)
}
mode := stat.Mode()
is := mode&os.ModeCharDevice == 0
return is
}
func getJsonsOrBlank() iter.Seq[string] {
@@ -76,7 +82,7 @@ func getJsonsOrBlank() iter.Seq[string] {
return true
})
if !hasStdin && !isPiped() {
if !hasStdin {
yield("{}")
}