diff --git a/.codeclimate.yml b/.codeclimate.yml index 1bececb..fa1f89d 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -6,6 +6,8 @@ engines: languages: javascript: mass_threshold: 70 + exclude_paths: + - test/ eslint: enabled: true channel: eslint-2 @@ -18,3 +20,4 @@ ratings: - "**.js" exclude_paths: - node_modules/ +- test/data/ diff --git a/Commands/init.js b/Commands/init.js index 71c019f..6b908e1 100644 --- a/Commands/init.js +++ b/Commands/init.js @@ -168,17 +168,8 @@ module.exports = { }) - .catch(function catchError(err) { - res.red(err.message).ln(); - /* istanbul ignore if*/ - if (typeof app.config.app !== "undefined" && app.config.app.debug) { - res.red(err.stack.replace(err.message, '')); - } - /* istanbul ignore if*/ - if (bug) { - bug.captureException(err); - } - res.prompt(); + .catch(function catchError(error) { + utils.displayError(error, res); }); } diff --git a/Commands/laravelConfig.js b/Commands/laravelConfig.js index 60bc928..24c606d 100644 --- a/Commands/laravelConfig.js +++ b/Commands/laravelConfig.js @@ -1,5 +1,5 @@ 'use strict'; -/* global app,appdir,bug */ +/* global app,appdir */ /* eslint global-require: 0 */ var Promise = require('bluebird'); var shelljs = require('shelljs'); @@ -232,17 +232,8 @@ module.exports = { utils.displayMessage(result, res); res.prompt(); }) - .catch(function laravelConfigError(err) { - res.red(err.message).ln(); - /* istanbul ignore if*/ - if (typeof app.config.app !== "undefined" && app.config.app.debug) { - res.red(err.stack.replace(err.message, '')); - } - /* istanbul ignore if*/ - if (bug) { - bug.captureException(err); - } - res.prompt(); + .catch(function catchError(error) { + utils.displayError(error, res); }); } }; diff --git a/Commands/makeCommand.js b/Commands/makeCommand.js index 9098b8e..9affc52 100644 --- a/Commands/makeCommand.js +++ b/Commands/makeCommand.js @@ -1,8 +1,9 @@ 'use strict'; -/* global app,appdir,Promise,bug */ +/* global appdir,Promise */ var jsBeautify = require('js-beautify').js_beautify; var fs = require('fs-promise'); +var utils = require('../lib/utilsCmd'); var createCommand = function createCommand(cmdName) { return new Promise(function promiseCreateCommand(resolve, reject) { @@ -34,17 +35,8 @@ module.exports = { res.prompt(); }) - .catch(function catchError(err) { - res.red(err.message).ln(); - /* istanbul ignore if*/ - if (typeof app.config.app !== "undefined" && app.config.app.debug) { - res.red(err.stack.replace(err.message, '')); - } - /* istanbul ignore if*/ - if (bug) { - bug.captureException(err); - } - res.prompt(); + .catch(function catchError(error) { + utils.displayError(error, res); }); } }; diff --git a/Commands/missingJob.js b/Commands/missingJob.js index bebb3e0..649ef3f 100644 --- a/Commands/missingJob.js +++ b/Commands/missingJob.js @@ -1,5 +1,5 @@ 'use strict'; -/* global config,appdir,Promise,logger,app,bug */ +/* global config,appdir,Promise,logger */ var console = logger(config.core.log.prefix + ':missingJob'); global.Queue = require('../lib/queue'); var jsBeautify = require('js-beautify').js_beautify; @@ -117,17 +117,8 @@ module.exports = { res.prompt(); // res.prompt(); }); - }).catch(function allWriteKo(err) { - res.red(err.message).ln(); - /* istanbul ignore if*/ - if (typeof app.config.app !== "undefined" && app.config.app.debug) { - res.red(err.stack.replace(err.message, '')); - } - /* istanbul ignore if*/ - if (bug) { - bug.captureException(err); - } - res.prompt(); + }).catch(function catchError(error) { + utils.displayError(error, res); }); } diff --git a/Commands/modelsCreator.js b/Commands/modelsCreator.js index c993986..b7c11a3 100644 --- a/Commands/modelsCreator.js +++ b/Commands/modelsCreator.js @@ -1,5 +1,5 @@ 'use strict'; -/* global app,bug */ +/* global app */ /* eslint global-require: 0 */ var utils = require('../lib/utilsCmd'); @@ -17,17 +17,8 @@ module.exports = { utils.displayMessage(result, res); res.prompt(); - }).catch(function modelCreatorError(err) { - res.red(err.message).ln(); - /* istanbul ignore if*/ - if (typeof app.config.app !== "undefined" && app.config.app.debug) { - res.red(err.stack.replace(err.message, '')); - } - /* istanbul ignore if*/ - if (bug) { - bug.captureException(err); - } - res.prompt(); + }).catch(function catchError(error) { + utils.displayError(error, res); }); } diff --git a/lib/utilsCmd.js b/lib/utilsCmd.js index 6922e15..c8315d1 100644 --- a/lib/utilsCmd.js +++ b/lib/utilsCmd.js @@ -1,5 +1,7 @@ 'use strict'; +/* global app,bug */ /* eslint no-invalid-this:0*/ + var jsBeautify = require('js-beautify').js_beautify; var each = require('lodash/each'); @@ -30,6 +32,18 @@ module.exports = { each(result, function eachMessage(message) { res.green(message).ln(); }); + }, + displayError: function catchError(err, res) { + res.red(err.message).ln(); + /* istanbul ignore if*/ + if (typeof app.config.app !== "undefined" && app.config.app.debug) { + res.red(err.stack.replace(err.message, '')); + } + /* istanbul ignore if*/ + if (bug) { + bug.captureException(err); + } + res.prompt(); } };