-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpreload.cjs
22 lines (19 loc) · 969 Bytes
/
preload.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const { contextBridge, ipcRenderer } = require('electron');
const Store = require('electron-store');
const store = new Store();
contextBridge.exposeInMainWorld('electron', {
openRepo: async (...args) => await ipcRenderer.invoke('open-repo', ...args),
openTerminal: async (...args) => await ipcRenderer.invoke('open-terminal', ...args),
callGit: async (...args) => await ipcRenderer.invoke('call-git', ...args),
readFile: async (...args) => await ipcRenderer.invoke('read-file', ...args),
writeFile: async (...args) => await ipcRenderer.invoke('write-file', ...args),
deleteFile: async (...args) => await ipcRenderer.invoke('delete-file', ...args),
addListener: (event_name, callback) => {
ipcRenderer.addListener(event_name, callback);
return () => ipcRenderer.removeListener(event_name, callback);
},
store: {
get: (...args) => store.get(...args),
set: (...args) => store.set(...args),
},
});