Skip to content

Instantly share code, notes, and snippets.

@lfsmoura
Created July 28, 2018 23:16
Show Gist options
  • Save lfsmoura/98609ac252568d45aa127cd0798624a7 to your computer and use it in GitHub Desktop.
Save lfsmoura/98609ac252568d45aa127cd0798624a7 to your computer and use it in GitHub Desktop.
File exists, confirm dialog, Electron
function fileExists(path) {
try {
return fs.statSync(path);
} catch (e) {
return false;
}
}
const exist = fileExists(path);
if (exist) {
const response = dialog.showMessageBox({
type: 'info',
buttons: ['Sim', 'Não'],
message: 'Já existe um arquivo aqui. Você tem certeza que deseja substituí-lo?',
});
if (response !== 1) {
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment