Skip to content

Commit e8c524b

Browse files
committed
configs: removed ArduinoIDEFolder global
It's not used anywhere and duplicated in configs and common packages
1 parent 157fc5f commit e8c524b

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

commands/root/root.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ func initConfigs() {
173173
logrus.Info("Configuration set")
174174
commands.GlobalFlags.Configs = c
175175
common.ArduinoDataFolder = pathutils.NewConstPath(commands.GlobalFlags.Configs.ArduinoDataFolder)
176-
common.ArduinoIDEFolder = pathutils.NewConstPath(configs.ArduinoIDEFolder)
177176
common.SketchbookFolder = pathutils.NewConstPath(commands.GlobalFlags.Configs.SketchbookPath)
178177
}
179178

common/paths.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ import (
3939
"github.com/bcmi-labs/arduino-cli/task"
4040
)
4141

42-
// ArduinoIDEFolder represents the current folder where the Arduino IDE relies, not used if CLI is not bundled with the IDE.
43-
var ArduinoIDEFolder pathutils.Path
44-
4542
// ArduinoDataFolder represents the current root of the arduino tree (defaulted to `$HOME/.arduino15` on linux).
4643
var ArduinoDataFolder = pathutils.NewPath("Arduino Data", getDefaultArduinoDataFolder, true)
4744

configs/configs.go

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ import (
5050
// ConfigFilePath represents the default location of the config file (same directory as executable).
5151
var ConfigFilePath = detectConfigFilePath()
5252

53-
// bundledInIDE tells if the CLI is paired with the Java Arduino IDE.
54-
var bundledInIDE *bool
55-
56-
// ArduinoIDEFolder represents the path of the IDE directory, set only if BundledInIDE = true.
57-
var ArduinoIDEFolder string
58-
5953
func detectConfigFilePath() string {
6054
fileLocation, err := os.Executable()
6155
if err != nil {
@@ -180,14 +174,17 @@ func fixMissingFields(c *Configs) {
180174
}
181175
}
182176

177+
var arduinoIDEDirectory *string
178+
183179
// Bundled returns if the CLI is bundled with the Arduino IDE.
184180
func Bundled() bool {
185-
if bundledInIDE != nil {
186-
return *bundledInIDE
181+
if arduinoIDEDirectory != nil {
182+
return *arduinoIDEDirectory != ""
187183
}
188-
bundledInIDE = new(bool)
184+
empty := ""
185+
arduinoIDEDirectory = &empty
186+
189187
logrus.Info("Checking if CLI is Bundled into the IDE")
190-
*bundledInIDE = false
191188
executable, err := os.Executable()
192189
if err != nil {
193190
logrus.WithError(err).Warn("Cannot get executable path")
@@ -198,19 +195,19 @@ func Bundled() bool {
198195
logrus.WithError(err).Warn("Cannot get executable path (symlinks error)")
199196
return false
200197
}
201-
ArduinoIDEFolder := filepath.Dir(filepath.Dir(executable))
202-
203-
logrus.Info("Candidate IDE Folder:", ArduinoIDEFolder)
198+
ideDir := filepath.Dir(filepath.Dir(executable))
199+
logrus.Info("Candidate IDE Directory:", ideDir)
204200

205201
executables := []string{"arduino", "arduino.sh", "arduino.exe"}
206202
for _, exe := range executables {
207-
exePath := filepath.Join(ArduinoIDEFolder, exe)
203+
exePath := filepath.Join(ideDir, exe)
208204
_, err := os.Stat(exePath)
209205
if !os.IsNotExist(err) {
210-
logrus.WithError(err).Info("CLI is bundled")
211-
*bundledInIDE = true
206+
arduinoIDEDirectory = &ideDir
207+
logrus.Info("CLI is bundled:", *arduinoIDEDirectory)
212208
break
213209
}
214210
}
215-
return false
211+
212+
return *arduinoIDEDirectory != ""
216213
}

0 commit comments

Comments
 (0)