fixed an issue that caused the program to crash if the item did not exist when opening the item.

This commit is contained in:
unknown 2024-04-11 19:36:37 +08:00
parent d117397dc3
commit e7ce285ae9

View File

@ -318,12 +318,16 @@ function execute(
// 工作目录 // 工作目录
let currentDir = startLocation; let currentDir = startLocation;
if (!currentDir || currentDir.trim() === "") { if (!currentDir || currentDir.trim() === "") {
try {
let statRes = statSync(file); let statRes = statSync(file);
if (statRes.isDirectory()) { if (statRes.isDirectory()) {
currentDir = file; currentDir = file;
} else { } else {
currentDir = dirname(file); currentDir = dirname(file);
} }
} catch (e) {
currentDir = app.getPath("home");
}
} }
// 组装命令 // 组装命令
let cmd: string; let cmd: string;