Skip to content

Commit

Permalink
[Fix] inconsistent return
Browse files Browse the repository at this point in the history
  • Loading branch information
d3v2a committed Jan 3, 2019
1 parent 27ae9bb commit 5871173
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"accessor-pairs": 2,
"block-scoped-var": 2,
"complexity": [2, 15],
"consistent-return": 0,
"consistent-return": 2,
"curly": 2,
"default-case": 1,
"dot-location": 0,
Expand Down
3 changes: 2 additions & 1 deletion Commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ var checkArtisan = function checkArtisan(cmdRes) {
return new Promise(function promiseCheckArtisan(resolve, reject) {
var test = cmdRes.match(/\s*Laravel\s+Framework\s+(version)?\s+(.*)/);
if (test) {
return resolve(test);
resolve(test);
return;
}
reject(new Error('not a laravel framework'));
});
Expand Down
3 changes: 2 additions & 1 deletion Commands/laravelConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ var prepareTmpFolder = function prepareTmpFolder() {
unsafeCleanup: true
}, function tmpDirCallback(err, name) {
if (err) {
return reject(err);
reject(err);
return;
}
fs.mkdir(name + '/Config-laravel')
.then(function tmpdirOk() {
Expand Down
6 changes: 4 additions & 2 deletions Commands/missingJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ module.exports = {
if (!app.config('app')) {
res.red('app config missing').ln();
res.yellow('see manual for setup config from laravel').ln();
return res.prompt();
res.prompt();
return;
}
if (Object.keys(app.config('app.job', [])).length === 0) {
res.yellow('no job in Config/app.js').ln();
return res.prompt();
res.prompt();
return;
}
global.queueOption = {};
Job = includeAll({
Expand Down
3 changes: 2 additions & 1 deletion Commands/modelsCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ module.exports = {
function: function run(req, res) {
if (app.config('core.modelsCreator.models').length === 0) {
res.yellow('Please add models to import in Config/core.js').ln();
return res.prompt();
res.prompt();
return;
}
var dbModels = require('../lib/db-models');
dbModels()
Expand Down
3 changes: 1 addition & 2 deletions lib/Config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
/* global app */

var include = require('include-all');
var fs = require('fs');
Expand Down Expand Up @@ -30,7 +29,7 @@ var Config = function Config(appdir, logger) {
Config.prototype.get = function get(key, def) {
var reduce = function reduce(obj, index) {
if (!obj) {
return;
return null;
}
return obj[index];
};
Expand Down
9 changes: 6 additions & 3 deletions lib/Mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ Mail.prototype.send = function sendMail(callback) {
self.mailer.sendMail(mailOptions, function mailerSendMail(err, info) {
if (err) {
if (callback) {
return callback(err);
callback(err);
return;
}
return reject(err);
reject(err);
return;
}
if (callback) {
return callback(null, info);
callback(null, info);
return;
}
resolve(info);
});
Expand Down
11 changes: 7 additions & 4 deletions lib/db-models/lib/Model-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ ModelExport.prototype.createOutputDir = function createOutputDir() {
return new Promise(function PromiseCreateOutputDir(resolve) {
fs.stat(self.dir, function statDir(err, stats) {
if (err || !stats.isDirectory()) {
return fs.mkdir(self.dir, function mkdir(mkdirErr) {
fs.mkdir(self.dir, function mkdir(mkdirErr) {
if (!mkdirErr) {
return resolve(true);
resolve(true);
return;
}
});
return;
}
return resolve(true);
resolve(true);
return;
});
});
};
Expand Down Expand Up @@ -105,7 +108,7 @@ ModelExport.prototype.createModels = function createModels() {
}
//for future association
self.associate[lowerName] = modelName;
return generatePromises.push(self.generateTemps({
generatePromises.push(self.generateTemps({
tableName: table,
modelName: modelName,
fields: results[1][table]
Expand Down
3 changes: 1 addition & 2 deletions lib/shell/lib/Shell.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
/* global app */
/*eslint no-magic-numbers: 0 */

var EventEmitter, Interface, Request, Response, shell, events, readline;
Expand Down Expand Up @@ -219,7 +218,7 @@ shell = (function exportShell(_super) {
} else if (this.parent) {
return this.parent.set(setting);
}

return this;
};

Shell.prototype.prompt = function prompt() {
Expand Down
12 changes: 8 additions & 4 deletions lib/shell/lib/plugins/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ module.exports = function help(settings) {
var route = routes[shell.routeName[command]];
if (!route) {
res.red('command ' + command + ' not found');
return res.prompt();
res.prompt();
return;
}
res.yellow('Help:').ln();
res.print(pad('', firstPad)).white(route.description).ln().ln();
Expand Down Expand Up @@ -90,7 +91,8 @@ module.exports = function help(settings) {
res.ln();
});

return res.prompt();
res.prompt();
return;
}
var routeText;
res.yellow('Available commands:');
Expand All @@ -102,14 +104,16 @@ module.exports = function help(settings) {
res.print(pad('', firstPad)).green(routeText).white(rte.description).ln();
}
});
return res.prompt();
res.prompt();
return;
};
console.log('add routes');
shell.cmd('help {command(([\\w\\:])*)?}', 'Show this message', shell.help.bind(shell));
shell.cmd('', shell.help.bind(shell));
if (shell.isShell && settings.introduction) {
text = typeof settings.introduction === 'string' ? settings.introduction : introduction;
return shell.styles.println(text);
shell.styles.println(text);
return;
}
};

8 changes: 4 additions & 4 deletions lib/shell/lib/plugins/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ var match = function match(req, routes) {
if ((/^\-\-/).test(arg)) {
arg = arg.replace('--', '');
route.options[arg] = true;
return;
return ;
}
if (keyArg >= keys.length) {
return;
return ;
}
param = keys.shift();
key = param.key;
Expand All @@ -83,7 +83,7 @@ var match = function match(req, routes) {
req._route_index = routeKey;
// throw new Error('missing parameter');
routeOk = route;
return false;
return;
}
});
// console.debug('routes:',routes);
Expand Down Expand Up @@ -121,7 +121,7 @@ module.exports = function router(settings) {
var args, route;
args = Array.prototype.slice.call(arguments);
if (!args[0]) {
return;
return this;
}
route = {};
route.command = args.shift();
Expand Down
2 changes: 1 addition & 1 deletion lib/shell/lib/routes/shellOnly.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ module.exports = function shellOnly(req, res, next) {
res.prompt();
return;
}
return next();
next();
};
1 change: 1 addition & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = {
return path.normalize(dir + '/..');
}
}
throw new Error('Workspace not found');
}
};

0 comments on commit 5871173

Please sign in to comment.