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

Commit 0122379

Browse files
alexsomesanyaohaizh
authored andcommitted
New setting - commandPath - custom arduino launch script (#451)
* Implement commandPath setting to allow customizing the Arduino executable name * Documentation for new 'commandPath' settings option
1 parent 000ae31 commit 0122379

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ The following Visual Studio Code settings are available for the Arduino extensio
5555
```json
5656
{
5757
"arduino.path": "C:/Program Files (x86)/Arduino",
58+
"arduino.commandPath": "run-arduino.bat",
5859
"arduino.additionalUrls": "",
59-
"arduino.logLevel": "info",
60+
"arduino.logLevel": "info",
6061
"arduino.enableUSBDetection": true
6162
}
6263
```
6364
- `arduino.path` - Path to Arduino, you can use a custom version of Arduino by modifying this setting to include the full path. Example: `C:\\Program Files\\Arduino` for Windows, `/Applications` for Mac, `/home/$user/Downloads/arduino-1.8.1` for Linux. (Requires a restart after change). The default value is automatically detected from your Arduino IDE installation path.
65+
- `arduino.commandPath` - Path to an executable (or script) relative to `arduino.path`. You can use a custom launch script to run Arduino by modifying this setting. (Requires a restart after change) Example: `run-arduino.bat` for Windows, `Contents/MacOS/run-arduino.sh` for Mac, `bin/run-arduino.sh` for Linux."
6466
- `arduino.additionalUrls` - Additional URLs for 3rd party packages. You can have multiple URLs in one string with comma(,) as separator, or have a string array. The default value is empty.
6567
- `arduino.logLevel` - CLI output log level. Could be info or verbose. The default value is `"info"`.
6668
- `arduino.enableUSBDetection` - Enable/disable USB detection from the VSCode Arduino extension. The default value is `true`.

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@
413413
"default": "",
414414
"description": "Path to Arduino, you can use a custom version of Arduino by modifying this setting to include the full path. Example: 'C:\\Program Files\\Arduino' for Windows, '/Applications' for Mac, '/home/$user/Downloads/arduino-1.8.1' for Linux. (Requires a restart after change)"
415415
},
416+
"arduino.commandPath": {
417+
"type": "string",
418+
"default": "",
419+
"description": "Path to a script relative to 'arduino.path', you can use a custom launch script to run Arduino by modifying this setting. Example: 'run-arduino.bat' for Windows, 'Contents/MacOS/run-arduino.sh' for Mac, 'bin/run-arduino.sh' for Linux. (Requires a restart after change)"
420+
},
416421
"arduino.additionalUrls": {
417422
"type": [
418423
"string",

src/arduino/arduinoSettings.ts

+15-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export interface IArduinoSettings {
2727
export class ArduinoSettings implements IArduinoSettings {
2828
private _arduinoPath: string;
2929

30+
private _commandPath: string;
31+
3032
private _packagePath: string;
3133

3234
private _sketchbookPath: string;
@@ -38,15 +40,25 @@ export class ArduinoSettings implements IArduinoSettings {
3840

3941
public async initialize() {
4042
const platform = os.platform();
43+
this._commandPath = VscodeSettings.getInstance().commandPath;
4144
await this.tryResolveArduinoPath();
4245
if (platform === "win32") {
4346
await this.updateWindowsPath();
47+
if (this._commandPath === "") {
48+
this._commandPath = "arduino_debug.exe";
49+
}
4450
} else if (platform === "linux") {
4551
this._packagePath = path.join(process.env.HOME, ".arduino15");
4652
this._sketchbookPath = this.preferences.get("sketchbook.path") || path.join(process.env.HOME, "Arduino");
53+
if (this._commandPath === "") {
54+
this._commandPath = "arduino";
55+
}
4756
} else if (platform === "darwin") {
4857
this._packagePath = path.join(process.env.HOME, "Library/Arduino15");
4958
this._sketchbookPath = this.preferences.get("sketchbook.path") || path.join(process.env.HOME, "Documents/Arduino");
59+
if (this._commandPath === "") {
60+
this._commandPath = "/Contents/MacOS/Arduino";
61+
}
5062
}
5163
}
5264

@@ -85,11 +97,9 @@ export class ArduinoSettings implements IArduinoSettings {
8597
public get commandPath(): string {
8698
const platform = os.platform();
8799
if (platform === "darwin") {
88-
return path.join(util.resolveMacArduinoAppPath(this._arduinoPath), path.normalize("/Contents/MacOS/Arduino"));
89-
} else if (platform === "linux") {
90-
return path.join(this._arduinoPath, "arduino");
91-
} else if (platform === "win32") {
92-
return path.join(this._arduinoPath, "arduino_debug.exe");
100+
return path.join(util.resolveMacArduinoAppPath(this._arduinoPath), path.normalize(this._commandPath));
101+
} else {
102+
return path.join(this._arduinoPath, path.normalize(this._commandPath));
93103
}
94104
}
95105

src/arduino/vscodeSettings.ts

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as vscode from "vscode";
55

66
const configKeys = {
77
ARDUINO_PATH: "arduino.path",
8+
ARDUINO_COMMAND_PATH: "arduino.commandPath",
89
ADDITIONAL_URLS: "arduino.additionalUrls",
910
LOG_LEVEL: "arduino.logLevel",
1011
AUTO_UPDATE_INDEX_FILES: "arduino.autoUpdateIndexFiles",
@@ -13,6 +14,7 @@ const configKeys = {
1314

1415
export interface IVscodeSettings {
1516
arduinoPath: string;
17+
commandPath: string;
1618
additionalUrls: string | string[];
1719
logLevel: string;
1820
enableUSBDetection: boolean;
@@ -35,6 +37,10 @@ export class VscodeSettings implements IVscodeSettings {
3537
return this.getConfigValue<string>(configKeys.ARDUINO_PATH);
3638
}
3739

40+
public get commandPath(): string {
41+
return this.getConfigValue<string>(configKeys.ARDUINO_COMMAND_PATH);
42+
}
43+
3844
public get additionalUrls(): string | string[] {
3945
return this.getConfigValue<string | string[]>(configKeys.ADDITIONAL_URLS);
4046
}

0 commit comments

Comments
 (0)