Skip to content

Commit db6f837

Browse files
committed
fix: reuse existing license if user didn't set any
GitHub now supports creating files like LICENSE for newly created repos. Running `cobra-cli init` after cloning a newly created repo will now empty that existing license.
1 parent 1d43487 commit db6f837

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

cmd/project.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,17 @@ func (p *Project) createLicenseFile() error {
7272
data := map[string]interface{}{
7373
"copyright": copyrightLine(),
7474
}
75-
licenseFile, err := os.Create(fmt.Sprintf("%s/LICENSE", p.AbsolutePath))
75+
76+
licensePath := p.AbsolutePath + "/LICENSE"
77+
78+
if p.Legal.Name == "none" {
79+
// If user didn't set any license and an existing license file is found, use that.
80+
if _, err := os.Stat(licensePath); err == nil {
81+
return nil
82+
}
83+
}
84+
85+
licenseFile, err := os.Create(licensePath)
7686
if err != nil {
7787
return err
7888
}

0 commit comments

Comments
 (0)