Skip to content

Commit

Permalink
fix files that dont match any template not creating dir structure pro…
Browse files Browse the repository at this point in the history
…perly
  • Loading branch information
atomicptr committed Jul 24, 2024
1 parent cc19c93 commit 4cd216a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cli
import (
"fmt"
"os"
"path/filepath"

"github.com/atomicptr/tmplr/pkg/fs"
"github.com/atomicptr/tmplr/pkg/meta"
Expand Down Expand Up @@ -51,6 +52,12 @@ func Run() error {
matchingTemplates := tmpl.FindMatchingTemplates(arg, templateFiles)

if len(matchingTemplates) == 0 {
dir := filepath.Dir(arg)
err = os.MkdirAll(dir, os.ModePerm)
if err != nil {
return err
}

err = os.WriteFile(arg, []byte(""), os.ModePerm)
if err != nil {
return err
Expand Down

0 comments on commit 4cd216a

Please sign in to comment.