Skip to content

Commit

Permalink
fix(cmd): correct permissions of created files and folders (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmvolod authored Aug 15, 2022
1 parent 4118600 commit 8850369
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/gomarkdoc/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func TestCommand_embed(t *testing.T) {
data, err := os.ReadFile("./embed/README-template.md")
is.NoErr(err)

err = os.WriteFile("./embed/README-test.md", data, 0644)
err = os.WriteFile("./embed/README-test.md", data, 0664)
is.NoErr(err)

main()
Expand Down
4 changes: 2 additions & 2 deletions cmd/gomarkdoc/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ func writeFile(fileName string, text string) error {
folder := filepath.Dir(fileName)

if folder != "" {
if err := os.MkdirAll(folder, 0664); err != nil {
if err := os.MkdirAll(folder, 0755); err != nil {
return fmt.Errorf("failed to create folder %s: %w", folder, err)
}
}

if err := ioutil.WriteFile(fileName, []byte(text), 0755); err != nil {
if err := ioutil.WriteFile(fileName, []byte(text), 0664); err != nil {
return fmt.Errorf("failed to write file %s: %w", fileName, err)
}

Expand Down
4 changes: 4 additions & 0 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func Generate() error {
return shellcmd.Command(`go generate .`).Run()
}

func Build() error {
return shellcmd.Command(`go build -o ./bin/gomarkdoc ./cmd/gomarkdoc`).Run()
}

func Doc() error {
return shellcmd.RunAll(
`go run ./cmd/gomarkdoc .`,
Expand Down

0 comments on commit 8850369

Please sign in to comment.