Skip to content
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
79 changes: 41 additions & 38 deletions src/setup/SetupPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,8 @@ export class SetupPanel {
});
SetupPanel.postMessage({
command: "setEspIdfErrorStatus",
errorMsg: `ESP-IDF is installed in ${
setupArgs.existingIdfSetups[message.selectedIdfSetup].idfPath
}`,
errorMsg: `ESP-IDF is installed in ${setupArgs.existingIdfSetups[message.selectedIdfSetup].idfPath
}`,
});
this.panel.webview.postMessage({
command: "updateEspIdfToolsStatus",
Expand Down Expand Up @@ -325,40 +324,44 @@ export class SetupPanel {
await commands.executeCommand("esp.component-manager.ui.show");
break;
case "canAccessFile":
if (message.path) {
const pathIdfPy = path.join(message.path, "tools", "idf.py");
// Only require read and execute permissions
const fileExists = await canAccessFile(pathIdfPy, fs.constants.R_OK | fs.constants.X_OK);
if (!fileExists) {
this.panel.webview.postMessage({
command: "canAccessFileResponse",
path: message.path,
exists: fileExists,
});
} else {
let versionEspIdf;
if (
message.currentVersion &&
typeof message.currentVersion === "string"
) {
versionEspIdf = message.currentVersion;
} else {
versionEspIdf = await getEspIdfFromCMake(message.path);
}
// compareVersion returns a negative value if versionEspIdf is less than "5.0"
const noWhiteSpaceSupport =
compareVersion(versionEspIdf, "5.0") < 0;
const hasWhitespace = /\s/.test(message.path);
this.panel.webview.postMessage({
command: "canAccessFileResponse",
path: message.path,
exists: fileExists,
noWhiteSpaceSupport,
hasWhitespace,
});
}
if (!message.path) {
break;
}

const pathIdfPy = path.join(message.path, "tools", "idf.py");
// Only require read and execute permissions
const fileExists = await canAccessFile(pathIdfPy, fs.constants.R_OK | fs.constants.X_OK);
if (!fileExists) {
this.panel.webview.postMessage({
command: "canAccessFileResponse",
path: pathIdfPy,
exists: fileExists,
});
break;
}

let versionEspIdf: string;
if (
message.currentVersion &&
typeof message.currentVersion === "string"
) {
versionEspIdf = message.currentVersion;
} else {
versionEspIdf = await getEspIdfFromCMake(message.path);
}
// compareVersion returns a negative value if versionEspIdf is less than "5.0"
const noWhiteSpaceSupport =
compareVersion(versionEspIdf, "5.0") < 0;
const hasWhitespace = /\s/.test(message.path);
this.panel.webview.postMessage({
command: "canAccessFileResponse",
path: pathIdfPy,
exists: fileExists,
noWhiteSpaceSupport,
hasWhitespace,
});
break;

default:
break;
}
Expand Down Expand Up @@ -425,7 +428,7 @@ export class SetupPanel {
) as string;
const progressLocation =
notificationMode === idfConf.NotificationMode.All ||
notificationMode === idfConf.NotificationMode.Notifications
notificationMode === idfConf.NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
return await window.withProgress(
Expand Down Expand Up @@ -559,7 +562,7 @@ export class SetupPanel {
) as string;
const progressLocation =
notificationMode === idfConf.NotificationMode.All ||
notificationMode === idfConf.NotificationMode.Notifications
notificationMode === idfConf.NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
return await window.withProgress(
Expand Down Expand Up @@ -629,7 +632,7 @@ export class SetupPanel {
) as string;
const progressLocation =
notificationMode === idfConf.NotificationMode.All ||
notificationMode === idfConf.NotificationMode.Notifications
notificationMode === idfConf.NotificationMode.Notifications
? ProgressLocation.Notification
: ProgressLocation.Window;
return await window.withProgress(
Expand Down
2 changes: 1 addition & 1 deletion src/views/setup/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ window.addEventListener("message", (event) => {
case "canAccessFileResponse":
if (!msg.exists) {
store.setIdfPathError(
"The path for ESP-IDF is not valid: /tools/idf.py not found."
`The path for ESP-IDF is not valid: ${msg.path} not found.`
);
} else if (msg.noWhiteSpaceSupport && msg.hasWhitespace) {
store.setIdfPathError(
Expand Down
2 changes: 1 addition & 1 deletion src/views/setup/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const useSetupStore = defineStore("setup", () => {
if (message.command === "canAccessFileResponse") {
if (!message.exists) {
setIdfPathError(
"The path for ESP-IDF is not valid: /tools/idf.py not found."
`The path for ESP-IDF is not valid: ${message.path} not found.`
);
} else {
setIdfPathError("");
Expand Down