Booting the application


#1

Hello!

I need some help with refactoring a mess.

const cp = require('copy-dir');

const createWindow = ()=> {
    fs.access('/path/to/jedmud/profile', (err)=> {
        if (err) {
            console.log('Cannot access configuration file');
            process.exit(1);
        }

        // do some BrowserWindow magic
    });
};

app.on('ready', ()=> {
    fs.access('/path/to/jedmud', (err)=> {
        if (err) {
            cp('/path/jedmud', '/path/to/jedmud', (err)=> {
                if (err) {
                    console.log('Cannot create user folder');
                    process.exit(1);
                }

                createWindow();
            });
        } else {
            createWindow();
        }
    });
});

What would be the right way to clean these blocks up?

So basically i need to check some files and folders before launching the application.