mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 09:23:09 +00:00
Map postprocess command stderr to os.Stderr
This commit is contained in:
parent
44a669faf1
commit
0ec2162aeb
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -38,13 +37,13 @@ func (t Task) Format(p *Page) (string, []byte) {
|
||||||
if t.PostProcess != "" {
|
if t.PostProcess != "" {
|
||||||
split := strings.Split(t.PostProcess, " ")
|
split := strings.Split(t.PostProcess, " ")
|
||||||
cmd := exec.Command(split[0], split[1:]...)
|
cmd := exec.Command(split[0], split[1:]...)
|
||||||
buf := new(bytes.Buffer)
|
|
||||||
cmd.Stdin = strings.NewReader(p.Content)
|
cmd.Stdin = strings.NewReader(p.Content)
|
||||||
cmd.Stdout = buf
|
cmd.Stderr = os.Stderr
|
||||||
if err := cmd.Run(); err != nil {
|
output, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
return path, buf.Bytes()
|
return path, output
|
||||||
}
|
}
|
||||||
|
|
||||||
return path, []byte(p.Content)
|
return path, []byte(p.Content)
|
||||||
|
|
Loading…
Reference in a new issue