Ensure target dir for mock exists (#112)

Fixes: #111
This commit is contained in:
Lucas Bremgartner 2019-11-03 16:12:56 +01:00 committed by Mat Ryer
parent ea57f91120
commit 382bd174c0

View File

@ -8,6 +8,7 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath"
"github.com/matryer/moq/pkg/moq" "github.com/matryer/moq/pkg/moq"
) )
@ -54,6 +55,10 @@ func main() {
} }
// create the file // create the file
if len(*outFile) > 0 { if len(*outFile) > 0 {
err = os.MkdirAll(filepath.Dir(*outFile), 0755)
if err != nil {
return
}
err = ioutil.WriteFile(*outFile, buf.Bytes(), 0644) err = ioutil.WriteFile(*outFile, buf.Bytes(), 0644)
} }
} }