Skip to content

Commit 402e685

Browse files
committed
Fix file name extraction in main process
The import didn't work this way in a production build. A simple replace does the job.
1 parent 5ae2b03 commit 402e685

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

public/electron.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ const { app } = electron;
99
const { BrowserWindow, dialog } = electron;
1010
const nativeImage = electron.nativeImage;
1111

12-
const { extractFileName } = require('../src/utils/fileNameProcessor');
13-
1412
if (process.env.DEV) {
1513
const {
1614
default: installExtension,
@@ -190,7 +188,7 @@ ipcMain.handle('OPEN_EXPORT_WINDOW', async (event, filePath) => {
190188
const dirPath = result.filePaths[0];
191189
if (dirPath) {
192190
var message = 'Export successful';
193-
const fileName = extractFileName(filePath);
191+
const fileName = filePath.replace(/.*\//, '');
194192
fs.copyFile(filePath, `${dirPath}/${fileName}`, err => {
195193
if (err) {
196194
console.log(err);

src/utils/fileNameProcessor.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,3 @@ exports.fileNameTrimmer = (n, len) => {
77
filename = filename.substr(0, len) + (n.length > len ? '...' : '');
88
return filename + '.' + ext;
99
};
10-
11-
exports.extractFileName = filePath => {
12-
const fileArray = filePath.split('/');
13-
return fileArray[fileArray.length - 1];
14-
};

0 commit comments

Comments
 (0)