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

Commit 3d761bc

Browse files
committed
Add more freedom on Mac with different version of Arduino
1 parent b5f1c2e commit 3d761bc

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/arduino/arduinoSettings.ts

+20-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ export class ArduinoSettings implements IArduinoSettings {
5656

5757
public get defaultExamplePath(): string {
5858
if (os.platform() === "darwin") {
59-
return path.join(this._arduinoPath, "Arduino.app/Contents/Java/examples");
59+
if (this._arduinoPath.match(/Arduino.*\.app/)){
60+
return path.join(this._arduinoPath, "/Contents/Java/examples");
61+
}else{
62+
return path.join(this._arduinoPath, "Arduino.app/Contents/Java/examples");
63+
}
6064
} else {
6165
return path.join(this._arduinoPath, "examples");
6266
}
@@ -68,15 +72,23 @@ export class ArduinoSettings implements IArduinoSettings {
6872

6973
public get defaultPackagePath(): string {
7074
if (os.platform() === "darwin") {
71-
return path.join(this._arduinoPath, "Arduino.app/Contents/Java/hardware");
75+
if (this._arduinoPath.match(/Arduino.*\.app/)){
76+
return path.join(this._arduinoPath, "/Contents/Java/hardware");
77+
}else{
78+
return path.join(this._arduinoPath, "Arduino.app/Contents/Java/hardware");
79+
}
7280
} else { // linux and win32.
7381
return path.join(this._arduinoPath, "hardware");
7482
}
7583
}
7684

7785
public get defaultLibPath(): string {
7886
if (os.platform() === "darwin") {
79-
return path.join(this._arduinoPath, "Arduino.app/Contents/Java/libraries");
87+
if (this._arduinoPath.match(/Arduino.*\.app/)){
88+
return path.join(this._arduinoPath, "/Contents/Java/libraries");
89+
}else{
90+
return path.join(this._arduinoPath, "Arduino.app/Contents/Java/libraries");
91+
}
8092
} else { // linux and win32
8193
return path.join(this._arduinoPath, "libraries");
8294
}
@@ -85,7 +97,11 @@ export class ArduinoSettings implements IArduinoSettings {
8597
public get commandPath(): string {
8698
const platform = os.platform();
8799
if (platform === "darwin") {
88-
return path.join(this._arduinoPath, path.normalize("Arduino.app/Contents/MacOS/Arduino"));
100+
if (this._arduinoPath.match(/Arduino.*\.app/)){
101+
return path.join(this._arduinoPath, path.normalize("/Contents/MacOS/Arduino"));
102+
}else{
103+
return path.join(this._arduinoPath, path.normalize("Arduino.app/Contents/MacOS/Arduino"));
104+
}
89105
} else if (platform === "linux") {
90106
return path.join(this._arduinoPath, "arduino");
91107
} else if (platform === "win32") {

src/common/sys/darwin.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ export function resolveArduinoPath(): string {
1919
}
2020

2121
export function validateArduinoPath(arduinoPath: string): boolean {
22-
return fileExistsSync(path.join(arduinoPath, "Arduino.app/Contents/MacOS/Arduino"));
22+
if (arduinoPath.match(/Arduino.*\.app/)){
23+
return fileExistsSync(path.join(arduinoPath, "/Contents/MacOS/Arduino"));
24+
}else{
25+
return fileExistsSync(path.join(arduinoPath, "Arduino.app/Contents/MacOS/Arduino"));
26+
}
2327
}
2428

2529
export function findFile(fileName: string, cwd: string): string {

0 commit comments

Comments
 (0)