Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
fix example issue for protable mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Sneezry authored Mar 29, 2018
1 parent 65f3e23 commit da12fe5
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions src/arduino/arduinoSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,17 @@ export class ArduinoSettings implements IArduinoSettings {
} else {
this._packagePath = path.join(process.env.HOME, ".arduino15");
}
this._sketchbookPath = this.preferences.get("sketchbook.path") || path.join(process.env.HOME, "Arduino");

if (this.preferences.get("sketchbook.path")) {
if (util.directoryExistsSync(path.join(this._arduinoPath, "portable"))) {
this._sketchbookPath = path.join(this._arduinoPath, "portable", this.preferences.get("sketchbook.path"));
} else {
this._sketchbookPath = this.preferences.get("sketchbook.path");
}
} else {
this._sketchbookPath = path.join(process.env.HOME, "Arduino");
}

if (this._commandPath === "") {
this._commandPath = "arduino";
}
Expand All @@ -63,7 +73,17 @@ export class ArduinoSettings implements IArduinoSettings {
} else {
this._packagePath = path.join(process.env.HOME, "Library/Arduino15");
}
this._sketchbookPath = this.preferences.get("sketchbook.path") || path.join(process.env.HOME, "Documents/Arduino");

if (this.preferences.get("sketchbook.path")) {
if (util.directoryExistsSync(path.join(this._arduinoPath, "portable"))) {
this._sketchbookPath = path.join(this._arduinoPath, "portable", this.preferences.get("sketchbook.path"));
} else {
this._sketchbookPath = this.preferences.get("sketchbook.path");
}
} else {
this._sketchbookPath = path.join(process.env.HOME, "Documents/Arduino");
}

if (this._commandPath === "") {
this._commandPath = "/Contents/MacOS/Arduino";
}
Expand Down Expand Up @@ -128,7 +148,13 @@ export class ArduinoSettings implements IArduinoSettings {

public reloadPreferences() {
this._preferences = util.parseConfigFile(this.preferencePath);
this._sketchbookPath = this._preferences.get("sketchbook.path") || this._sketchbookPath;
if (this.preferences.get("sketchbook.path")) {
if (util.directoryExistsSync(path.join(this._arduinoPath, "portable"))) {
this._sketchbookPath = path.join(this._arduinoPath, "portable", this.preferences.get("sketchbook.path"));
} else {
this._sketchbookPath = this.preferences.get("sketchbook.path");
}
}
}

/**
Expand Down Expand Up @@ -159,7 +185,16 @@ export class ArduinoSettings implements IArduinoSettings {
} else {
this._packagePath = path.join(process.env.LOCALAPPDATA, "Arduino15");
}
this._sketchbookPath = this.preferences.get("sketchbook.path") || path.join(folder, "Arduino");

if (this.preferences.get("sketchbook.path")) {
if (util.directoryExistsSync(path.join(this._arduinoPath, "portable"))) {
this._sketchbookPath = path.join(this._arduinoPath, "portable", this.preferences.get("sketchbook.path"));
} else {
this._sketchbookPath = this.preferences.get("sketchbook.path");
}
} else {
this._sketchbookPath = path.join(folder, "Arduino");
}
}

private async tryResolveArduinoPath(): Promise<void> {
Expand Down

0 comments on commit da12fe5

Please sign in to comment.