Skip to content

Commit 471fb68

Browse files
authored
1 parent 8c0a924 commit 471fb68

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/common/sys/win32.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ export async function resolveArduinoPath() {
1616
if (directoryExistsSync(pathString)) {
1717
return pathString;
1818
}
19-
pathString = childProcess.execSync("where arduino", {encoding: "utf8"});
20-
pathString = path.resolve(pathString).trim();
21-
if (fileExistsSync(pathString)) {
22-
pathString = path.dirname(path.resolve(pathString));
19+
try {
20+
pathString = childProcess.execSync("where arduino", { encoding: "utf8" });
21+
pathString = path.resolve(pathString).trim();
22+
if (fileExistsSync(pathString)) {
23+
pathString = path.dirname(path.resolve(pathString));
24+
}
25+
} catch (error) {
26+
// when "where arduino"" execution fails, the childProcess.execSync will throw error, just ignore it
2327
}
28+
2429
return pathString;
2530
}
2631

@@ -32,7 +37,7 @@ export function findFile(fileName: string, cwd: string): string {
3237
let result;
3338
try {
3439
let pathString;
35-
pathString = childProcess.execSync(`dir ${fileName} /S /B`, {encoding: "utf8", cwd}).split("\n");
40+
pathString = childProcess.execSync(`dir ${fileName} /S /B`, { encoding: "utf8", cwd }).split("\n");
3641
if (pathString && pathString[0] && fileExistsSync(pathString[0].trim())) {
3742
result = path.normalize(pathString[0].trim());
3843
}

0 commit comments

Comments
 (0)