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

fix bug: libPath contains environment variables on win32 #175

Merged
merged 2 commits into from
Mar 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion html/app/styles/board.scss
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ a {

.toolbar-mask {
position: absolute;
z-index: 9999;
z-index: 9998;
left: 20px;
right: 20px;
text-align: end;
Expand Down
25 changes: 17 additions & 8 deletions src/arduino/arduino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,15 @@ export class ArduinoApp {
public async installBoard(packageName: string, arch: string, version: string = "", showOutput: boolean = true) {
arduinoChannel.show();
arduinoChannel.start(`Install package - ${packageName}...`);
await util.spawn(this._settings.commandPath,
showOutput ? arduinoChannel.channel : null,
["--install-boards", `${packageName}:${arch}${version && ":" + version}`]);
arduinoChannel.end(`Installed board package - ${packageName}${os.EOL}`);
try {
await util.spawn(this._settings.commandPath,
showOutput ? arduinoChannel.channel : null,
["--install-boards", `${packageName}:${arch}${version && ":" + version}`]);

arduinoChannel.end(`Installed board package - ${packageName}${os.EOL}`);
} catch (error) {
arduinoChannel.error(`Exit with code=${error.code}${os.EOL}`);
}
}

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

arduinoChannel.end(`Installed libarray - ${libName}${os.EOL}`);
arduinoChannel.end(`Installed library - ${libName}${os.EOL}`);
} catch (error) {
arduinoChannel.error(`Exit with code=${error.code}${os.EOL}`);
}
}

public uninstallLibrary(libName: string, libPath: string) {
Expand Down
7 changes: 6 additions & 1 deletion src/arduino/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,12 @@ export class ArduinoSettings implements IArduinoSettings {
resolve(docFolder);
}
}).then((folder: string) => {
this._libPath = path.join(folder, "Arduino/libraries");
// For some case, docFolder parsed from win32 registry looks like "%USERPROFILE%\Documents,
// Should replace the environment variables with actual value.
folder = folder.replace(/%([^%]+)%/g, (match, p1) => {
return process.env[p1];
});
this._libPath = path.normalize(path.join(folder, "Arduino/libraries"));
if (util.fileExistsSync(path.join(arduinoPath, "AppxManifest.xml"))) {
this._packagePath = path.join(folder, "ArduinoData");
} else {
Expand Down