diff --git a/lib/platform/index.js b/lib/platform/index.js index 711d984ccc3b96829894e0884bd20891410dd537..25bc0a941fd13f0ba60451add08abdd2c009fa53 100644 --- a/lib/platform/index.js +++ b/lib/platform/index.js @@ -1,17 +1,20 @@ -const github = require('./github'); -const gitlab = require('./gitlab'); -const vsts = require('./vsts'); +/* eslint-disable global-require */ +const platforms = new Map([ + ['github', require('./github')], + ['gitlab', require('./gitlab')], + ['vsts', require('./vsts')], +]); +/* eslint-enable global-require */ -function initPlatform(val) { - if (val === 'github') { - global.platform = github; - } else if (val === 'gitlab') { - global.platform = gitlab; - } else if (val === 'vsts') { - global.platform = vsts; - } +function getPlatformApi(platform) { + return platforms.get(platform); +} + +function initPlatform(platform) { + global.platform = getPlatformApi(platform); } module.exports = { initPlatform, + getPlatformApi, };