diff options
| author | Nicolas Paul <n@nc0.fr> | 2023-05-31 13:27:34 +0200 |
|---|---|---|
| committer | Nicolas Paul <n@nc0.fr> | 2023-05-31 13:27:34 +0200 |
| commit | c7c30a42c372accecc55bc794ad7699642f7644b (patch) | |
| tree | 957891bdd0137edabb010b2bb6966b185dd0d64f | |
| parent | 3e64b1b9323ea17eb8f87dfed6d897683c6196be (diff) | |
Support modules with nested names (path include directories), e.g. foo/bar/module_name
Signed-off-by: Nicolas Paul <n@nc0.fr>
| -rw-r--r-- | pkg/types/module.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/pkg/types/module.go b/pkg/types/module.go index 7a09f8b..e0ec5ea 100644 --- a/pkg/types/module.go +++ b/pkg/types/module.go @@ -5,6 +5,7 @@ import ( "go.nc0.fr/svgu/pkg/templates" "os" "path" + "strings" ) // Vcs is an enum for version control systems supported by the standard Go @@ -37,6 +38,12 @@ func (m *Module) GenerateFile(out string, domain string) error { f := path.Join(out, m.Path+".html") // Create the file. + if strings.Contains(m.Path, "/") { + if err := os.MkdirAll(path.Dir(f), 0755); err != nil { + return err + } + } + fd, err := os.Create(f) if err != nil { return err |
