feat(desktop-ui): View and edit .goosehints file (#1431)

This commit is contained in:
Matthew Diamant
2025-02-27 16:48:58 -08:00
committed by GitHub
parent 6d28f44768
commit fe6cb72677
4 changed files with 202 additions and 0 deletions
+35
View File
@@ -623,6 +623,41 @@ app.whenReady().then(async () => {
spawn('xdg-open', [url]);
}
});
ipcMain.handle('read-file', (event, filePath) => {
return new Promise((resolve) => {
exec(`cat ${filePath}`, (error, stdout, stderr) => {
if (error) {
// File not found
resolve({ file: "", filePath, error: null, found: false });
}
if (stderr) {
console.error('Error output:', stderr);
resolve({ file: "", filePath, error, found: false });
}
resolve({ file: stdout, filePath, error: null, found: true });
});
})
})
ipcMain.handle('write-file', (event, filePath, content) => {
return new Promise((resolve) => {
const command = `cat << 'EOT' > ${filePath}
${content}
EOT`;
exec(command, (error, stdout, stderr) => {
if (error) {
console.error('Error writing to file:', error);
resolve(false);
}
if (stderr) {
console.error('Error output:', stderr);
resolve(false);
}
resolve(true);
});
});
});
});
// Quit when all windows are closed, except on macOS.