index.js 589 B

123456789101112131415161718192021
  1. "use strict";
  2. /**
  3. *
  4. * First function to be called after running a flag. This is a check,
  5. * to match the flag with the respective require.
  6. *
  7. * @param {String} command - which feature to use
  8. * @param {Object} args - arguments from the CLI
  9. * @returns {Function} invokes the module with the supplied command
  10. *
  11. */
  12. module.exports = function initialize(command, args) {
  13. if (!command) {
  14. throw new Error(`Unknown command ${command} found`);
  15. } else if (command === "serve") {
  16. return require(`./commands/${command}`).serve();
  17. }
  18. return require(`./commands/${command}`)(...args);
  19. };