Skip to content

Commit

Permalink
Set directory & file permission (#109)
Browse files Browse the repository at this point in the history
Signed-off-by: Steffen Exler <Steffen.Exler@mail.schwarz>
  • Loading branch information
linuxluigi committed Apr 30, 2022
1 parent 1593fef commit 692b7dd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/gotemplate/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import (
"github.com/schwarzit/go-template/pkg/gocli"
)

const minGoVersion = "1.15"
const (
minGoVersion = "1.15"
permissionDirectory = 0755
permissionFile = 0644
)

var (
ErrAlreadyExists = errors.New("already exists")
Expand Down Expand Up @@ -207,7 +211,7 @@ func (gt *GT) InitNewProject(opts *NewRepositoryOptions) (err error) {

pathToWrite = strings.ReplaceAll(pathToWrite, gotemplate.Key, targetDir)
if d.IsDir() {
return os.MkdirAll(pathToWrite, os.ModePerm)
return os.MkdirAll(pathToWrite, permissionDirectory)
}

fileBytes, err := fs.ReadFile(gotemplate.FS, path)
Expand All @@ -220,7 +224,7 @@ func (gt *GT) InitNewProject(opts *NewRepositoryOptions) (err error) {
return err
}

return os.WriteFile(pathToWrite, []byte(data), os.ModePerm)
return os.WriteFile(pathToWrite, []byte(data), permissionFile)
})
if err != nil {
return err
Expand Down

0 comments on commit 692b7dd

Please sign in to comment.