feat: render directory structure instead of flat file names (#20)

* feat: render directory structure instead of flat file names

* add gitignore
This commit is contained in:
Jeroen Op 't Eynde 2021-06-04 15:33:41 +02:00 committed by GitHub
parent 1f8d4c6fbf
commit 5776ff829f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 9 deletions

View file

@ -17,7 +17,12 @@ func To(pkg docsonnet.Package, dir string, opts Opts) (int, error) {
n := 0
for k, v := range data {
if err := ioutil.WriteFile(filepath.Join(dir, k), []byte(v), 0644); err != nil {
fullpath := filepath.Join(dir, k)
dir := filepath.Dir(fullpath)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
return n, err
}
if err := ioutil.WriteFile(fullpath, []byte(v), 0644); err != nil {
return n, err
}
n++