Skip to content

Commit

Permalink
Bugfix: opening file with preferred application on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
amitnovick committed Aug 12, 2019
1 parent 449d627 commit 296ec21
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions app/renderer/fs/openFileByName.js
@@ -1,26 +1,10 @@
import formatFilePath from './formatFilePath';

const childProcess = require('child_process');

const getOpenProgramName = () => {
switch (process.platform) {
case 'darwin':
return 'open';
case 'win32':
return 'start';
case 'win64':
return 'start';
default:
return 'xdg-open';
}
};
import { shell } from 'electron';

const openFileByName = (fileName) => {
const filePath = formatFilePath(fileName);
const openProgramProcess = childProcess.exec(`${getOpenProgramName()} "${filePath}"`);
openProgramProcess.stderr.on('data', (data) => {
console.log('Error while trying to open file:', data);
});
shell.openItem(filePath);
};

export default openFileByName;

0 comments on commit 296ec21

Please sign in to comment.