From 24c324c5b64476ae3a31d933433cae8f51c147eb Mon Sep 17 00:00:00 2001
From: Steven Hargrove <steven.hargrove@weather.com>
Date: Wed, 4 Apr 2018 13:29:38 +0200
Subject: [PATCH] refactor: initPlatform

---
 lib/platform/index.js | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/lib/platform/index.js b/lib/platform/index.js
index 711d984ccc..25bc0a941f 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,
 };
-- 
GitLab