Skip to content

Commit 6c5dfae

Browse files
authored
Create LaunchAgents/ directory if it doesn't exist (MacOS) (#811)
Signed-off-by: Tristan B <[email protected]>
1 parent 604da4a commit 6c5dfae

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

config/autostart.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ var launchdAgentDefinition []byte
3131

3232
// getLaunchdAgentPath will return the path of the launchd agent default path
3333
func getLaunchdAgentPath() *paths.Path {
34-
return GetDefaultHomeDir().Join("Library", "LaunchAgents", "ArduinoCreateAgent.plist")
34+
homeDir := GetDefaultHomeDir()
35+
launchAgentsPath := homeDir.Join("Library", "LaunchAgents")
36+
agentPlistPath := launchAgentsPath.Join("ArduinoCreateAgent.plist")
37+
38+
if err := os.MkdirAll(launchAgentsPath.String(), 0755); err != nil {
39+
log.Panicf("Could not create ~/Library/LaunchAgents directory: %s", err)
40+
}
41+
42+
return agentPlistPath
3543
}
3644

3745
// InstallPlistFile will handle the process of creating the plist file required for the autostart

0 commit comments

Comments
 (0)