Skip to content

Commit

Permalink
Make directory for files before writing them
Browse files Browse the repository at this point in the history
  • Loading branch information
brimstone committed Dec 22, 2018
1 parent ae021ed commit 4118b67
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion files.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"io/ioutil"
"log"
"os"
"path/filepath"
)

func init() {
Expand All @@ -14,8 +16,12 @@ func init() {

func initFiles() bool {
for _, f := range config.Files {
err := os.MkdirAll(filepath.Dir(f.Path), 0777)
if err != nil {
return false
}
log.Printf("Writing %s\n", f.Path)
err := ioutil.WriteFile(f.Path, []byte(f.Content), 0777)
err = ioutil.WriteFile(f.Path, []byte(f.Content), 0777)
if err != nil {
return false
}
Expand Down

0 comments on commit 4118b67

Please sign in to comment.