updated run flag to create new profile each time

This commit is contained in:
partisan 2024-12-14 18:09:56 +01:00
parent 504fc59573
commit a21ff16308

View file

@ -6,6 +6,7 @@ import (
"os/exec"
"path/filepath"
"runtime"
"time"
)
// Array to store errors
@ -243,15 +244,32 @@ func RunProject(sourcePath string) {
return
}
// Run the binary
cmd := exec.Command(binaryPath)
// Create a unique profile directory for each run
profilePath := filepath.Join(buildDir, fmt.Sprintf("profile_%d", time.Now().UnixNano()))
if err := os.Mkdir(profilePath, 0755); err != nil {
fmt.Printf("Failed to create profile directory: %v\n", err)
return
}
// Run the binary with the new profile
cmd := exec.Command(binaryPath, "-no-remote", "-profile", profilePath)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
fmt.Printf("Running binary: %s\n", binaryPath)
fmt.Printf("Running binary: %s with new profile at %s\n", binaryPath, profilePath)
if err := cmd.Run(); err != nil {
fmt.Printf("Failed to run the project: %v\n", err)
} else {
fmt.Println("Binary execution finished successfully.")
}
// Delete the profile directory after execution
fmt.Printf("Deleting profile directory: %s\n", profilePath)
if err := os.RemoveAll(profilePath); err != nil {
fmt.Printf("Failed to delete profile directory: %v\n", err)
} else {
fmt.Println("Profile directory deleted successfully.")
}
}