Skip to content

Commit 272f583

Browse files
facchinmcmaglie
authored andcommitted
Recognize if IDE is portable and fix paths accordingly
1 parent 02ffe3c commit 272f583

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

configs/configuration.go

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ type Configuration struct {
3939
// ArduinoIDEDirectory is the directory of the Arduino IDE if the CLI runs together with it.
4040
ArduinoIDEDirectory *paths.Path
4141

42+
// IsPortable is set to true if the cli lives in IDE directory and the IDE is portable
43+
IsPortable bool
44+
4245
// downloadsDir is the directory where the package files are downloaded and cached.
4346
// Use DownloadsDir() method to retrieve it.
4447
downloadsDir *paths.Path

configs/preferences_txt_serializer.go

+10
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ func (config *Configuration) IsBundledInDesktopIDE() bool {
6262
}
6363
}
6464

65+
portable := "portable"
66+
if ideDir.Join(portable).Exist() {
67+
logrus.Info("IDE is portable")
68+
config.IsPortable = true
69+
}
70+
6571
config.ArduinoIDEDirectory = ideDir
6672
res = true
6773
return true
@@ -70,6 +76,10 @@ func (config *Configuration) IsBundledInDesktopIDE() bool {
7076
// LoadFromDesktopIDEPreferences loads the config from the Desktop IDE preferences.txt file
7177
func (config *Configuration) LoadFromDesktopIDEPreferences() error {
7278
logrus.Info("Unserializing from IDE preferences")
79+
if config.IsPortable {
80+
config.DataDir = config.ArduinoIDEDirectory.Join("portable")
81+
config.SketchbookDir = config.ArduinoIDEDirectory.Join("portable").Join("sketchbook")
82+
}
7383
preferenceTxtPath := config.DataDir.Join("preferences.txt")
7484
props, err := properties.LoadFromPath(preferenceTxtPath)
7585
if err != nil {

0 commit comments

Comments
 (0)