Skip to content

Commit

Permalink
Recognize if IDE is portable and fix paths accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
facchinm authored and cmaglie committed Jan 9, 2019
1 parent 02ffe3c commit 272f583
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions configs/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type Configuration struct {
// ArduinoIDEDirectory is the directory of the Arduino IDE if the CLI runs together with it.
ArduinoIDEDirectory *paths.Path

// IsPortable is set to true if the cli lives in IDE directory and the IDE is portable
IsPortable bool

// downloadsDir is the directory where the package files are downloaded and cached.
// Use DownloadsDir() method to retrieve it.
downloadsDir *paths.Path
Expand Down
10 changes: 10 additions & 0 deletions configs/preferences_txt_serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ func (config *Configuration) IsBundledInDesktopIDE() bool {
}
}

portable := "portable"
if ideDir.Join(portable).Exist() {
logrus.Info("IDE is portable")
config.IsPortable = true
}

config.ArduinoIDEDirectory = ideDir
res = true
return true
Expand All @@ -70,6 +76,10 @@ func (config *Configuration) IsBundledInDesktopIDE() bool {
// LoadFromDesktopIDEPreferences loads the config from the Desktop IDE preferences.txt file
func (config *Configuration) LoadFromDesktopIDEPreferences() error {
logrus.Info("Unserializing from IDE preferences")
if config.IsPortable {
config.DataDir = config.ArduinoIDEDirectory.Join("portable")
config.SketchbookDir = config.ArduinoIDEDirectory.Join("portable").Join("sketchbook")
}
preferenceTxtPath := config.DataDir.Join("preferences.txt")
props, err := properties.LoadFromPath(preferenceTxtPath)
if err != nil {
Expand Down

0 comments on commit 272f583

Please sign in to comment.