best practice re: early return w/ callback invocation

This commit is contained in:
Michael Bradley, Jr 2018-09-04 08:20:27 -05:00
parent c02199db0f
commit b67aa8cc2d
2 changed files with 10 additions and 13 deletions

View File

@ -32,11 +32,11 @@ class Server {
async.waterfall([
function createPlaceholderPage(next) {
if (self.isFirstStart) {
self.isFirstStart = false;
return self.events.request('build-placeholder', next);
if (!self.isFirstStart) {
return next();
}
next();
self.isFirstStart = false;
self.events.request('build-placeholder', next);
},
function listen(next) {
self.server.listen(self.port, self.hostname, () => {
@ -45,12 +45,9 @@ class Server {
});
},
function openBrowser(next) {
if (!self.opened) {
self.opened = true;
return self.events.request('open-browser', next);
if (self.opened) {
return next();
}
next();
},
function reportAvailable(next) {
next(null, __("webserver available at") +
" " +

View File

@ -29,11 +29,11 @@ class Pipeline {
async.waterfall([
function createPlaceholderPage(next){
if (!self.isFirstBuild) {
return self.events.request('build-placeholder', next);
if (self.isFirstBuild) {
self.isFirstBuild = false;
return next();
}
self.isFirstBuild = false;
next();
self.events.request('build-placeholder', next);
},
function buildTheContracts(next) {
self.buildContracts(next);