verless / verless

A Static Site Generator designed for Markdown-based content with a focus on simplicity and performance.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

verless create project: Don't remove .git directory

dominikbraun opened this issue · comments

Thanks to @alinnert for proposing this.

Currently, the verless create project command does, at least when the --overwrite flag is used, remove and re-create the entire directory. It would be nice to retain the .git directory so that a new project can be initialized within a Git repository.

The changes have to be made in this section here:

verless/core/create.go

Lines 55 to 72 in 83e8762

err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
// RemoveAll removes nested directory in first iteration which causes
// os.PathError saying "no such file or directory" for next recursion of
// WalkFunc.
if os.IsNotExist(err) {
return nil
}
if path != "." {
if info.IsDir() {
// Remove nested non-empty directories as os.Remove() only removes
// files and empty directories
return os.RemoveAll(path)
} else {
return os.Remove(path)
}
}
return nil
})