Skip to content

Commit 4dc21a4

Browse files
committed
enable ARDUINO_CREATE_AGENT_CONFIG env var to specify the config.ini
1 parent 240d8f8 commit 4dc21a4

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
@@ -186,13 +186,25 @@ func loop() {
186186
srcPath := paths.New(src)
187187
srcDir := srcPath.Parent()
188188

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

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

0 commit comments

Comments
 (0)