getSocketIntegration.js 897 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * Gets the socket integration to use for Webpack messages.
  3. * @param {'wds' | 'whm' | 'wps' | string} integrationType A valid socket integration type or a path to a module.
  4. * @returns {string} Path to the resolved socket integration module.
  5. */
  6. function getSocketIntegration(integrationType) {
  7. let resolvedSocketIntegration;
  8. switch (integrationType) {
  9. case 'wds': {
  10. resolvedSocketIntegration = require.resolve('../../sockets/WDSSocket');
  11. break;
  12. }
  13. case 'whm': {
  14. resolvedSocketIntegration = require.resolve('../../sockets/WHMEventSource');
  15. break;
  16. }
  17. case 'wps': {
  18. resolvedSocketIntegration = require.resolve('../../sockets/WPSSocket');
  19. break;
  20. }
  21. default: {
  22. resolvedSocketIntegration = require.resolve(integrationType);
  23. break;
  24. }
  25. }
  26. return resolvedSocketIntegration;
  27. }
  28. module.exports = getSocketIntegration;