Skip to content

Commit 18f47c7

Browse files
[VSC-1681 | 1304] isBinInPath remove use of which where (#1565)
* isBinInPath remove use of which where * call stat after path exists check * Fix binaryPath update * use canAccessFile * fix manual py path * rm remaining ref which where * rm utils dependency
1 parent 4d07b76 commit 18f47c7

File tree

15 files changed

+86
-118
lines changed

15 files changed

+86
-118
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ esp_debug_adapter/
2929
external/
3030
test-resources/
3131
docs_espressif/
32+
profiles

src/build/buildTask.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,10 @@ export class BuildTask {
8686
};
8787
const canAccessCMake = await isBinInPath(
8888
"cmake",
89-
this.currentWorkspace.fsPath,
9089
modifiedEnv
9190
);
9291
const canAccessNinja = await isBinInPath(
9392
"ninja",
94-
this.currentWorkspace.fsPath,
9593
modifiedEnv
9694
);
9795

src/clang/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export async function validateEspClangExists(workspaceFolder: Uri) {
3434

3535
const espClangdPath = await isBinInPath(
3636
"clangd",
37-
workspaceFolder.fsPath,
3837
modifiedEnv
3938
);
4039
if (espClangdPath && espClangdPath.includes("esp-clang")) {

src/espIdf/debugAdapter/debugAdapterManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class DebugAdapterManager extends EventEmitter {
9090
if (this.isRunning()) {
9191
return;
9292
}
93-
if (!isBinInPath("openocd", this.currentWorkspace.fsPath, this.env)) {
93+
if (!isBinInPath("openocd", this.env)) {
9494
return reject(
9595
new Error("Invalid OpenOCD bin path or access is denied for the user")
9696
);

src/espIdf/openOcd/openOcdManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class OpenOCDManager extends EventEmitter {
6161

6262
public async version(): Promise<string> {
6363
const modifiedEnv = await appendIdfAndToolsToPath(this.workspace);
64-
if (!isBinInPath("openocd", this.workspace.fsPath, modifiedEnv)) {
64+
if (!isBinInPath("openocd", modifiedEnv)) {
6565
return "";
6666
}
6767
const resp = await sspawn("openocd", ["--version"], {
@@ -157,7 +157,7 @@ export class OpenOCDManager extends EventEmitter {
157157
return;
158158
}
159159
const modifiedEnv = await appendIdfAndToolsToPath(this.workspace);
160-
if (!isBinInPath("openocd", this.workspace.fsPath, modifiedEnv)) {
160+
if (!isBinInPath("openocd", modifiedEnv)) {
161161
throw new Error(
162162
"Invalid OpenOCD bin path or access is denied for the user"
163163
);

src/espIdf/tracing/gdbHeapTraceManager.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export class GdbHeapTraceManager {
6868
const gdbTool = getToolchainToolName(idfTarget, "gdb");
6969
const isGdbToolInPath = await isBinInPath(
7070
gdbTool,
71-
workspace.fsPath,
7271
modifiedEnv
7372
);
7473
if (!isGdbToolInPath) {

src/pythonManager.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -518,27 +518,19 @@ export async function getUnixPythonList(workingDir: string) {
518518
let python3Versions: string[] = [];
519519

520520
try {
521-
const pythonVersionsRaw = await utils.execChildProcess(
522-
"which",
523-
["-a", "python"],
524-
workingDir
521+
pythonVersions = await utils.getAllBinPathInEnvPath(
522+
"python",
523+
process.env
525524
);
526-
pythonVersions = pythonVersionsRaw.trim()
527-
? pythonVersionsRaw.trim().split("\n")
528-
: [];
529525
} catch (pythonError) {
530526
Logger.warn("Error finding python versions", pythonError);
531527
}
532528

533529
try {
534-
const python3VersionsRaw = await utils.execChildProcess(
535-
"which",
536-
["-a", "python3"],
537-
workingDir
530+
python3Versions = await utils.getAllBinPathInEnvPath(
531+
"python3",
532+
process.env
538533
);
539-
python3Versions = python3VersionsRaw.trim()
540-
? python3VersionsRaw.trim().split("\n")
541-
: [];
542534
} catch (python3Error) {
543535
Logger.warn("Error finding python3 versions", python3Error);
544536
}

src/qemu/qemuManager.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ export class QemuManager extends EventEmitter {
184184
}
185185
const isQemuBinInPath = await isBinInPath(
186186
qemuExecutable,
187-
workspaceFolder.fsPath,
188187
modifiedEnv
189188
);
190189
if (!isQemuBinInPath) {

src/setup/espIdfJson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export async function addIdfPath(
9393
espIdfObj["idfSelectedId"] = idfId;
9494
if (!espIdfObj.gitPath) {
9595
if (gitPath === "git") {
96-
gitPath = await isBinInPath(gitPath, idfPath, process.env);
96+
gitPath = await isBinInPath(gitPath, process.env);
9797
}
9898
espIdfObj.gitPath = gitPath;
9999
}

src/setup/setupInit.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ export async function getSetupInitialValues(
171171

172172
const canAccessCMake = await utils.isBinInPath(
173173
"cmake",
174-
extensionPath,
175174
process.env
176175
);
177176

@@ -183,7 +182,6 @@ export async function getSetupInitialValues(
183182

184183
const canAccessNinja = await utils.isBinInPath(
185184
"ninja",
186-
extensionPath,
187185
process.env
188186
);
189187

@@ -246,15 +244,13 @@ export async function isCurrentInstallValid(workspaceFolder: Uri) {
246244
if (process.platform !== "win32") {
247245
const canAccessCMake = await utils.isBinInPath(
248246
"cmake",
249-
containerPath,
250247
process.env
251248
);
252249
if (!canAccessCMake) {
253250
extraReqPaths.push("cmake");
254251
}
255252
const canAccessNinja = await utils.isBinInPath(
256253
"ninja",
257-
containerPath,
258254
process.env
259255
);
260256
if (!canAccessNinja) {

0 commit comments

Comments
 (0)