Ghost/core/server/services/channels/loader.js
Hannah Wolfe 1445678035 Fixed channel path to work with Ghost-CLI
- Just, DERP 🙈
2017-11-10 20:52:50 +00:00

31 lines
991 B
JavaScript

var debug = require('ghost-ignition').debug('channels:loader'),
_ = require('lodash'),
path = require('path'),
Channel = require('./Channel'),
channels = [];
function loadConfig() {
var channelConfig = {};
// This is a very dirty temporary hack so that we can test out channels with some Beta testers
// If you are reading this code, and considering using it, best reach out to us on Slack
// Definitely don't be angry at us if the structure of the JSON changes or this goes away.
try {
channelConfig = require(path.join(process.cwd(), 'config.channels.json'));
} catch (err) {
channelConfig = require('./config.channels.json');
}
return channelConfig;
}
module.exports.list = function list() {
debug('Load channels start');
_.each(loadConfig(), function (channelConfig, channelName) {
channels.push(new Channel(channelName, channelConfig));
});
debug('Load channels end');
return channels;
};