Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (let moduleName of moduleList) {
if (rx.test(moduleName)) {
// found a sockethub platform
const platformName = moduleName.replace(rx, '');
log('registering ' + platformName + ' platform');
if (platformIsAccepted(platformName)) {
// try to load platform
const P = require(moduleName);
const p = new P();
const packageJson = require(`./../../node_modules/${moduleName}/package.json`);
let types = [];
// validate schema property
if (! tv4.validate(p.schema, schemas.platform)) {
throw new Error(
`${platformName} platform schema failed to validate: ${tv4.error.message}`);
} else if (typeof p.config !== 'object') {
throw new Error(
`${platformName} platform must have a config property that is an object.`);
} else if (p.schema.credentials) {
// register the platforms credentials schema
types.push('credentials');
tv4.addSchema(`http://sockethub.org/schemas/v0/context/${platformName}/credentials`,
p.schema.credentials);
}
tv4.addSchema(`http://sockethub.org/schemas/v0/context/${platformName}/messages`,
p.schema.messages);
if (platformListsSupportedTypes(p)) {