From 8850369ee997a11209643445b5a1a603b02433fa Mon Sep 17 00:00:00 2001 From: Dmitry Volodin Date: Mon, 15 Aug 2022 20:56:53 +0300 Subject: [PATCH] fix(cmd): correct permissions of created files and folders (#76) --- cmd/gomarkdoc/command_test.go | 2 +- cmd/gomarkdoc/output.go | 4 ++-- magefile.go | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/gomarkdoc/command_test.go b/cmd/gomarkdoc/command_test.go index 97f66b5..0c04d5b 100644 --- a/cmd/gomarkdoc/command_test.go +++ b/cmd/gomarkdoc/command_test.go @@ -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() diff --git a/cmd/gomarkdoc/output.go b/cmd/gomarkdoc/output.go index ccffcf9..a49877d 100644 --- a/cmd/gomarkdoc/output.go +++ b/cmd/gomarkdoc/output.go @@ -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) } diff --git a/magefile.go b/magefile.go index de98caa..b506636 100644 --- a/magefile.go +++ b/magefile.go @@ -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 .`,