Skip to content

Commit a874ad5

Browse files
committed
enable ARDUINO_CREATE_AGENT_CONFIG env var to specify the config.ini
1 parent 689fc8b commit a874ad5

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

main.go

+17-5
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,25 @@ func loop() {
187187
srcPath := paths.New(src)
188188
srcDir := srcPath.Parent()
189189

190-
configPath := srcDir.Join("config.ini")
190+
var configPath *paths.Path
191191

192-
if configPath.NotExist() {
193-
// probably we are on macOS, where the config is in a different dir
194-
configPath = srcDir.Parent().Join("Resources", "config.ini")
192+
// see if the env var is defined, if it is take the config from there
193+
envConfig := os.Getenv("ARDUINO_CREATE_AGENT_CONFIG")
194+
if envConfig != "" {
195+
configPath = paths.New(envConfig)
195196
if configPath.NotExist() {
196-
log.Panicf("config.ini file not found in %s", configPath)
197+
log.Panicf("config from env var %s does not exists", envConfig)
198+
}
199+
} else {
200+
// take the config from the folder where the binary sits
201+
configPath = srcDir.Join("config.ini")
202+
203+
if configPath.NotExist() {
204+
// probably we are on macOS, where the config is in a different dir
205+
configPath = srcDir.Parent().Join("Resources", "config.ini")
206+
if configPath.NotExist() {
207+
log.Panicf("config.ini file not found in %s", configPath)
208+
}
197209
}
198210
}
199211

0 commit comments

Comments
 (0)