Skip to content

Commit

Permalink
Create archive directory if it doesn't exist. (#1058)
Browse files Browse the repository at this point in the history
On an M1 Mac rename seems to fail if the containing directories do not
already exist.
  • Loading branch information
cmacknz authored Aug 31, 2022
1 parent 712b300 commit 5f1e54f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,8 +894,13 @@ func movePackagesToArchive(dropPath string, requiredPackages []string) string {
continue
}

targetPath := filepath.Join(archivePath, rp)
if err := os.Rename(f, filepath.Join(targetPath, filepath.Base(f))); err != nil {
targetDir := filepath.Join(archivePath, rp, filepath.Base(f))
targetPath := filepath.Join(targetDir, filepath.Base(f))
if err := os.MkdirAll(targetDir, 0750); err != nil {
fmt.Printf("warning: failed to create directory %s: %s", targetDir, err)
}

if err := os.Rename(f, targetPath); err != nil {
panic(errors.Wrap(err, "failed renaming file"))
}
}
Expand Down

0 comments on commit 5f1e54f

Please sign in to comment.