From d64b814acb166ac54026bf3b38539c23f21c7a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 4 Jan 2018 10:48:08 -0500 Subject: [PATCH] handle https://packages.nodebb.org failures --- src/plugins.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins.js b/src/plugins.js index 653edee5fe..f11ed63494 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -213,8 +213,8 @@ Plugins.list = function (matching, callback) { require('request')(url, { json: true, }, function (err, res, body) { - if (err) { - winston.error('Error parsing plugins', err); + if (err || (res && res.statusCode !== 200)) { + winston.error('Error loading ' + url, err || body); return Plugins.normalise([], callback); } @@ -225,7 +225,7 @@ Plugins.list = function (matching, callback) { Plugins.normalise = function (apiReturn, callback) { var pluginMap = {}; var dependencies = require(path.join(nconf.get('base_dir'), 'package.json')).dependencies; - apiReturn = apiReturn || []; + apiReturn = Array.isArray(apiReturn) ? apiReturn : []; for (var i = 0; i < apiReturn.length; i += 1) { apiReturn[i].id = apiReturn[i].name; apiReturn[i].installed = false;