Skip to content

Commit

Permalink
Fix commands execution for pwsh on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
radurentea committed Sep 30, 2024
1 parent 95910d8 commit f52780c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions src/espIdf/monitor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class IDFMonitor {
this.config = config;
}

start() {
async start() {
const modifiedEnv = appendIdfAndToolsToPath(this.config.workspaceFolder);
this.terminal = window.createTerminal({
name: `ESP-IDF Monitor ${this.config.wsPort ? "(--ws enabled)" : ""}`,
Expand Down Expand Up @@ -114,14 +114,16 @@ export class IDFMonitor {
const quotedIdfPath = quotePath(modifiedEnv.IDF_PATH);

if (shellType.includes("powershell") || shellType.includes("pwsh")) {
this.terminal.sendText(`$env:IDF_PATH = ${quotedIdfPath}`, true);
this.terminal.sendText(`& ${args.join(" ")}`, true);
this.terminal.sendText(`$env:IDF_PATH = ${quotedIdfPath};`);
// For pwsh users on Linux, we need to add delay between commands
await new Promise((resolve) => setTimeout(resolve, 1000));
this.terminal.sendText(` & ${args.join(" ")}\r`);
} else if (shellType.includes("cmd")) {
this.terminal.sendText(`${envSetCmd} IDF_PATH=${modifiedEnv.IDF_PATH}`, true);
this.terminal.sendText(args.join(" "), true);
this.terminal.sendText(`${envSetCmd} IDF_PATH=${modifiedEnv.IDF_PATH}`);
this.terminal.sendText(args.join(" "));
} else {
this.terminal.sendText(`${envSetCmd} IDF_PATH=${quotedIdfPath}`, true);
this.terminal.sendText(args.join(" "), true);
this.terminal.sendText(`${envSetCmd} IDF_PATH=${quotedIdfPath}`);
this.terminal.sendText(args.join(" "));
}

return this.terminal;
Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3967,7 +3967,7 @@ function createQemuMonitor(
monitorTerminal.sendText(ESP.CTRL_RBRACKET);
monitorTerminal.sendText(`exit`);
}
monitorTerminal = idfMonitor.start();
monitorTerminal = await idfMonitor.start();
});
}

Expand Down Expand Up @@ -4159,7 +4159,7 @@ async function createIdfMonitor(
monitorTerminal.sendText(ESP.CTRL_RBRACKET);
monitorTerminal.sendText(`exit`);
}
monitorTerminal = idfMonitor.start();
monitorTerminal = await idfMonitor.start();
if (noReset) {
const idfPath = idfConf.readParameter(
"idf.espIdfPath",
Expand Down

0 comments on commit f52780c

Please sign in to comment.