Skip to content

Commit

Permalink
refactor: use os chmod instead of exec
Browse files Browse the repository at this point in the history
  • Loading branch information
steveiliop56 committed Sep 18, 2024
1 parent 1179bb1 commit 06cb665
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions internal/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"net/http"
"os"
"os/exec"
"path"
"strconv"
"strings"
Expand Down Expand Up @@ -122,7 +121,7 @@ func DownloadCLI(version string) (error) {
return writeErr
}

_, chmodErr := exec.Command("chmod", "+x", cliPath).Output()
chmodErr := os.Chmod(cliPath, 0755)

if chmodErr != nil {
return chmodErr
Expand Down
24 changes: 12 additions & 12 deletions internal/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,24 @@ func EnsureFilePermissions() (error) {

for _, item := range items {
if slices.Contains(SevenSevenSevenItems, item.Name()) {
_, execErr := exec.Command("chmod", "-R", "777", item.Name()).Output()
if execErr != nil {
return execErr
chmodErr := os.Chmod(item.Name(), 0777)
if chmodErr != nil {
return chmodErr
}
} else if slices.Contains(SixSixSixItems, item.Name()) {
_, execErr := exec.Command("chmod", "-R", "666", item.Name()).Output()
if execErr != nil {
return execErr
chmodErr := os.Chmod(item.Name(), 0666)
if chmodErr != nil {
return chmodErr
}
} else if slices.Contains(SixSixFourItems, item.Name()) {
_, execErr := exec.Command("chmod", "-R", "664", item.Name()).Output()
if execErr != nil {
return execErr
chmodErr := os.Chmod(item.Name(), 0664)
if chmodErr != nil {
return chmodErr
}
} else if slices.Contains(SixOOItems, item.Name()) {
_, execErr := exec.Command("chmod", "-R", "600", item.Name()).Output()
if execErr != nil {
return execErr
chmodErr := os.Chmod(item.Name(), 0600)
if chmodErr != nil {
return chmodErr
}
}
}
Expand Down

0 comments on commit 06cb665

Please sign in to comment.