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

Commit b2c1401

Browse files
fix bug: libPath contains environment variables on win32 (#175)
* fix bug: libPath contains environment variables on win32 * move fix code to docFolder
1 parent dd4fdab commit b2c1401

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

html/app/styles/board.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ a {
146146

147147
.toolbar-mask {
148148
position: absolute;
149-
z-index: 9999;
149+
z-index: 9998;
150150
left: 20px;
151151
right: 20px;
152152
text-align: end;

src/arduino/arduino.ts

+17-8
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,15 @@ export class ArduinoApp {
180180
public async installBoard(packageName: string, arch: string, version: string = "", showOutput: boolean = true) {
181181
arduinoChannel.show();
182182
arduinoChannel.start(`Install package - ${packageName}...`);
183-
await util.spawn(this._settings.commandPath,
184-
showOutput ? arduinoChannel.channel : null,
185-
["--install-boards", `${packageName}:${arch}${version && ":" + version}`]);
186-
arduinoChannel.end(`Installed board package - ${packageName}${os.EOL}`);
183+
try {
184+
await util.spawn(this._settings.commandPath,
185+
showOutput ? arduinoChannel.channel : null,
186+
["--install-boards", `${packageName}:${arch}${version && ":" + version}`]);
187+
188+
arduinoChannel.end(`Installed board package - ${packageName}${os.EOL}`);
189+
} catch (error) {
190+
arduinoChannel.error(`Exit with code=${error.code}${os.EOL}`);
191+
}
187192
}
188193

189194
public uninstallBoard(boardName: string, packagePath: string) {
@@ -195,11 +200,15 @@ export class ArduinoApp {
195200
public async installLibrary(libName: string, version: string = "", showOutput: boolean = true) {
196201
arduinoChannel.show();
197202
arduinoChannel.start(`Install library - ${libName}`);
198-
await util.spawn(this._settings.commandPath,
199-
showOutput ? arduinoChannel.channel : null,
200-
["--install-library", `${libName}${version && ":" + version}`]);
203+
try {
204+
await util.spawn(this._settings.commandPath,
205+
showOutput ? arduinoChannel.channel : null,
206+
["--install-library", `${libName}${version && ":" + version}`]);
201207

202-
arduinoChannel.end(`Installed libarray - ${libName}${os.EOL}`);
208+
arduinoChannel.end(`Installed library - ${libName}${os.EOL}`);
209+
} catch (error) {
210+
arduinoChannel.error(`Exit with code=${error.code}${os.EOL}`);
211+
}
203212
}
204213

205214
public uninstallLibrary(libName: string, libPath: string) {

src/arduino/settings.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,12 @@ export class ArduinoSettings implements IArduinoSettings {
167167
resolve(docFolder);
168168
}
169169
}).then((folder: string) => {
170-
this._libPath = path.join(folder, "Arduino/libraries");
170+
// For some case, docFolder parsed from win32 registry looks like "%USERPROFILE%\Documents,
171+
// Should replace the environment variables with actual value.
172+
folder = folder.replace(/%([^%]+)%/g, (match, p1) => {
173+
return process.env[p1];
174+
});
175+
this._libPath = path.normalize(path.join(folder, "Arduino/libraries"));
171176
if (util.fileExistsSync(path.join(arduinoPath, "AppxManifest.xml"))) {
172177
this._packagePath = path.join(folder, "ArduinoData");
173178
} else {

0 commit comments

Comments
 (0)