Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip creating a file or directory if the path to the file or director… #31

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"regexp"
"strings"
"text/template"

"github.com/Ilyes512/boilr/pkg/boilr"
Expand Down Expand Up @@ -162,6 +163,18 @@ func (t *dirTemplate) Execute(dirPrefix string) error {

newName := buf.String()

if oldName != newName {
tlog.Debug(fmt.Sprintf("change name from %q to %q", oldName, newName))
}

splitPath := strings.Split(newName, string(filepath.Separator))
for _, s := range splitPath {
if s == "" {
tlog.Debug(fmt.Sprintf("skip creating a file or directory with an empty name %q -> %q", oldName, newName))
return nil
}
}

target := filepath.Join(dirPrefix, newName)

if info.IsDir() {
Expand Down