Fix launcher issues on macos #7

Fixes properties.json path not being found.
This commit is contained in:
daijro 2024-09-12 08:03:36 -05:00
parent 598a8566e2
commit 662e62fb2c
2 changed files with 11 additions and 3 deletions

View file

@ -115,7 +115,7 @@ func parseJson(argv string, target interface{}) {
if fileExists(argv) {
data, err = os.ReadFile(argv)
if err != nil {
fmt.Printf("Error reading config file: %v\n", err)
fmt.Printf("Error reading JSON file: %v\n", err)
os.Exit(1)
}
} else {
@ -124,7 +124,7 @@ func parseJson(argv string, target interface{}) {
}
if err := json.Unmarshal(data, target); err != nil {
fmt.Printf("Invalid JSON in config: %v\n", err)
fmt.Printf("Invalid JSON: %v\n", err)
os.Exit(1)
}
}

View file

@ -5,6 +5,7 @@ import (
"math"
"os"
"reflect"
"runtime"
)
type Property struct {
@ -36,8 +37,15 @@ func validateConfig(configMap map[string]interface{}) {
}
func loadProperties() []Property {
propertiesPath := getPath("properties.json")
// Get the path to the properties.json file
var propertiesPath string
if normalizeOS(runtime.GOOS) == "macos" {
propertiesPath = getPath("Camoufox.app/Contents/Resources/properties.json")
} else {
propertiesPath = getPath("properties.json")
}
var properties []Property
// Parse the JSON file
parseJson(propertiesPath, &properties)
return properties
}