From 03ece2894c3b636aee3e9d1bfcd2db6c59df2be4 Mon Sep 17 00:00:00 2001 From: Tristan B Date: Mon, 7 Aug 2023 21:25:54 -0600 Subject: [PATCH] Create `LaunchAgents/` directory if it doesn't exist (MacOS) Signed-off-by: Tristan B --- config/autostart.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/config/autostart.go b/config/autostart.go index 1f8d81fec..e45333d5b 100644 --- a/config/autostart.go +++ b/config/autostart.go @@ -31,7 +31,15 @@ var launchdAgentDefinition []byte // getLaunchdAgentPath will return the path of the launchd agent default path func getLaunchdAgentPath() *paths.Path { - return GetDefaultHomeDir().Join("Library", "LaunchAgents", "ArduinoCreateAgent.plist") + homeDir := GetDefaultHomeDir() + launchAgentsPath := homeDir.Join("Library", "LaunchAgents") + agentPlistPath := launchAgentsPath.Join("ArduinoCreateAgent.plist") + + if err := os.MkdirAll(launchAgentsPath.String(), 0755); err != nil { + log.Panicf("Could not create ~/Library/LaunchAgents directory: %s", err) + } + + return agentPlistPath } // InstallPlistFile will handle the process of creating the plist file required for the autostart