From d0a9d3ab2ff8cd323ecd21a12d68d6d400dfefb6 Mon Sep 17 00:00:00 2001 From: Jim Laurie Date: Wed, 2 Aug 2017 12:12:28 +0200 Subject: [PATCH] Fix silent fail log files --- .../controllers/SettingsManager.js | 7 ++++++- packages/strapi/bin/strapi-start.js | 13 +++++++------ packages/strapi/lib/core/hooks.js | 2 +- packages/strapi/lib/utils/index.js | 2 ++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/strapi-plugin-settings-manager/controllers/SettingsManager.js b/packages/strapi-plugin-settings-manager/controllers/SettingsManager.js index a0f4825253..bf180e652f 100644 --- a/packages/strapi-plugin-settings-manager/controllers/SettingsManager.js +++ b/packages/strapi-plugin-settings-manager/controllers/SettingsManager.js @@ -68,7 +68,12 @@ module.exports = { if (env && _.isEmpty(_.find(Service.getEnvironments(), { name: env }))) return ctx.badRequest(null, [{ messages: [{ id: 'request.error.environment.unknown' }] }]); - const model = _.has(Service, slug) ? Service[slug](env) : return ctx.badRequest(null, [{ messages: [{ id: 'request.error.config' }] }]);; + let model; + if (_.has(Service, slug)) { + model = Service[slug](env); + } else { + return ctx.badRequest(null, [{ messages: [{ id: 'request.error.config' }] }]); + } const items = Service.getItems(model); diff --git a/packages/strapi/bin/strapi-start.js b/packages/strapi/bin/strapi-start.js index a4c0d456bf..e6d1a81aa2 100644 --- a/packages/strapi/bin/strapi-start.js +++ b/packages/strapi/bin/strapi-start.js @@ -35,12 +35,13 @@ module.exports = function() { 'strapi' ); - let strapi; - if (isLocalStrapiValid(localStrapiPath, process.cwd())) { - strapi = require(localStrapiPath); - } else { - strapi = require('strapi'); - } + const strapi = function () { + try { + return require(path.resolve(process.cwd(), 'node_modules', 'strapi')); + } catch (e) { + return require('strapi'); + } + }(); // Set NODE_ENV if (_.isEmpty(process.env.NODE_ENV)) { diff --git a/packages/strapi/lib/core/hooks.js b/packages/strapi/lib/core/hooks.js index 35f095b662..723d053bcc 100644 --- a/packages/strapi/lib/core/hooks.js +++ b/packages/strapi/lib/core/hooks.js @@ -16,7 +16,7 @@ module.exports = function() { const cwd = ''; // Load configurations. - glob('./node_modules/strapi-*', {}, (err, files) => { + glob('./node_modules/strapi-*', { ignore: ['./node_modules/strapi-plugin-*'] }, (err, files) => { if (err) { return reject(err); } diff --git a/packages/strapi/lib/utils/index.js b/packages/strapi/lib/utils/index.js index 0887a20e9f..08fd72aae4 100644 --- a/packages/strapi/lib/utils/index.js +++ b/packages/strapi/lib/utils/index.js @@ -10,6 +10,8 @@ module.exports = { try { return require(path.resolve(this.config.appPath, url)); } catch (e) { + this.log.error(e); + return {}; } },