"Quick" save in electron with a conformation dialog
We can make the code simpler with a saveFile function

function saveFile(filename, data) {
    fs.writeFile(filename, content, (error) =&gt; {
        if (error) {
            dialog.showErrorBox(
                'Save Failed',
                `An error occured saving the file ${error.message}`,
            );
            return;
        }
        dialog.showMessageBox({
            type: 'none',
            title: 'Ganttron',
            message: 'The chart was successfully saved',
            buttons: ['OK'],
        });
    });
}

const quickSave = () =&gt; {
    let saveData = gantt.serialize();
    saveData = JSON.stringify(saveData, null, '\t');
    if (quickSaveFileName === undefined) {
        dialog.showSaveDialog({
                defaultPath: `C:\\Users\\${process.env.USERNAME}\\Documents\\`,
                filters: [{
                    name: 'json',
                    extensions: ['json'],
                }, ],
            },
            (filename) =&gt; {
                if (filename === undefined) {
                    return;
                }
                saveFile(quickSaveFileName, saveData);
            });
    } else {
        saveFile(quickSaveFileName, saveData);
    }
};