Provide a way to open app folder in finder (#42)

This commit is contained in:
Will Chen
2025-04-28 22:57:13 -07:00
committed by GitHub
parent 7ab1aab9b0
commit 674dc6aeb0
4 changed files with 54 additions and 5 deletions

View File

@@ -22,4 +22,24 @@ export function registerShellHandlers() {
return { success: false, error: (error as Error).message };
}
});
ipcMain.handle("show-item-in-folder", async (_event, fullPath: string) => {
try {
// Validate that a path was provided
if (!fullPath) {
logger.error("Attempted to show item with empty path");
return {
success: false,
error: "No file path provided.",
};
}
shell.showItemInFolder(fullPath);
logger.debug("Showed item in folder:", fullPath);
return { success: true };
} catch (error) {
logger.error(`Failed to show item in folder ${fullPath}:`, error);
return { success: false, error: (error as Error).message };
}
});
}

View File

@@ -292,8 +292,22 @@ export class IpcClient {
return result as { success: boolean; error?: string };
} catch (error) {
showError(error);
// Ensure a consistent return type even on invoke error
return { success: false, error: (error as Error).message };
throw error;
}
}
public async showItemInFolder(
fullPath: string
): Promise<{ success: boolean; error?: string }> {
try {
const result = await this.ipcRenderer.invoke(
"show-item-in-folder",
fullPath
);
return result as { success: boolean; error?: string };
} catch (error) {
showError(error);
throw error;
}
}