Skip to content

Commit

Permalink
Fixed up async loading of ready
Browse files Browse the repository at this point in the history
  • Loading branch information
twolfson committed Jun 18, 2019
1 parent ae93d14 commit ab1be45
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/electron-launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ if (program.require) {
async.parallel([
function loadExtendedOptions (cb) {
// If we have extended options, then load them in
console.log('hiii', program.extendedOptions);
if (program.extendedOptions) {
fs.readFile(program.extendedOptions, function handleReadFile (err, extendedOptionsStr) {
console.log('hiii', err, program.extendedOptionsStr);
fs.readFile(program.extendedOptions, 'utf8', function handleReadFile (err, extendedOptionsStr) {
// If we have an error, callback with it
if (err) { return cb(err); }

Expand All @@ -60,20 +58,25 @@ async.parallel([
var extendedOptions = JSON.parse(extendedOptionsStr);
} catch (err) {
console.error('Error loading extended options: ' + extendedOptionsStr);
throw err;
return cb(err);
}
Object.assign(program, extendedOptions);
cb();
cb(null);
});
// Otherwise, callback in an async behavior (to match `if` case)
} else {
process.nextTick(cb);
}
},
function waitForAppReady (cb) {
app.on('ready', cb);
app.on('ready', function handleReady (evt) {
cb(null);
});
}
], function handleParallelLoad () {
], function handleParallelLoad (err) {
// If we received an error, throw it
if (err) { throw err; }

// Create our browser window
var browserWindowOptions = Object.assign({
show: false
Expand Down

0 comments on commit ab1be45

Please sign in to comment.