Skip to content

Commit 86fe897

Browse files
fixed exported store
Co-authored-by: Anthony Herrera <anthonyHerr@users.noreply.github.com>
1 parent e64752c commit 86fe897

File tree

8 files changed

+831
-1313
lines changed

8 files changed

+831
-1313
lines changed

src-electron/electron-main.ts

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ function createWindow() {
1818
height: 600,
1919
useContentSize: true,
2020
webPreferences: {
21-
// JAIME: i tried adding these two below to make window.require('fs') work
2221
// nodeIntegration: true,
2322
// contextIsolation: false,
2423
contextIsolation: true,
@@ -85,11 +84,6 @@ if (mainWindow) {
8584
console.log("jsonFile is", jsonFile);
8685
return { jsonFile };
8786
}
88-
89-
//Kevin: I think calling readFileSync here in electron main is actually what we're supposed to do
90-
//and then we send the received data back to Import
91-
//because in here, readFileSync should be a function that has access to the res data
92-
9387
});
9488

9589

@@ -105,6 +99,16 @@ ipcMain.handle("exportProject", async (event, options) => {
10599
return { filePath };
106100
});
107101

102+
ipcMain.handle("useExportComponent", async (event, options) => {
103+
const { dialog } = require("electron");
104+
const { filePath } = await dialog.showSaveDialog(options);
105+
if (filePath === "") {
106+
throw new Error("No file path selected");
107+
}
108+
return { filePath };
109+
});
110+
111+
108112
ipcMain.handle('writeFile', async (event, filePath, content) => { //possibly merge this with 'writeJSON' handle
109113
// console.log('writeFile filePath:', filePath, '\n content:', content);
110114
console.log("writeFile filePath:", filePath);
@@ -117,32 +121,19 @@ ipcMain.handle('writeFile', async (event, filePath, content) => { //possibly mer
117121
});
118122
console.log('finished fs.writeSync')
119123
return { status: "success" };
120-
// return new Promise(async (resolve, reject) => {
121-
// await fs.writeFile(filePath, content, (err) => {
122-
// if (err) {
123-
// reject(err);
124-
// } else {
125-
// resolve("File written successfully");
126-
// }
127-
// });
128-
// });
124+
129125
});
130126

131-
// ipcMain.handle('existSync',(event, { path }) => {
132-
// return fs.existsSync(path)
133-
// });
127+
134128

135129
ipcMain.handle('check-file-exists', async (event, path) => {
136130
const fileExists = await fs.existsSync(path);
137131
console.log("fileExists", fileExists);
138-
139132
if (fileExists) return { status: true };
140133
return { status: false };
141134
});
142135

143136
ipcMain.handle('mkdirSync', async (event, args: string[] ) => {
144-
console.log('about to make new directory')
145-
console.log("args", args);
146137
const mkdirPath = await path.join(...args);
147138
console.log("mkdirPath", mkdirPath);
148139
await fs.mkdirSync(mkdirPath);
@@ -151,10 +142,7 @@ ipcMain.handle('mkdirSync', async (event, args: string[] ) => {
151142
});
152143

153144
ipcMain.handle('pathJoin', (event, ...args: any[]) => {//should expect args and output to be string
154-
// for(const arg:any of [...args])
155-
console.log('pathJoin args:', ...args);
156145
const newPath:string = path.join(...args);
157-
console.log('newPath', newPath)
158146
return newPath; //return string directly instead of object
159147
});
160148

0 commit comments

Comments
 (0)