No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

extractTriggers.js 961B

1234567891011121314151617181920212223
  1. "use strict";
  2. var extractTriggers = function (mod, triggers, prefix) {
  3. prefix = prefix || "";
  4. for (var funcName of Object.keys(mod)) {
  5. var child = mod[funcName];
  6. if (typeof child === "function" && child.__trigger && typeof child.__trigger === "object") {
  7. if (funcName.indexOf("-") >= 0) {
  8. throw new Error('Function name "' + funcName + '" is invalid. Function names cannot contain dashes.');
  9. }
  10. var trigger = {};
  11. for (var key of Object.keys(child.__trigger)) {
  12. trigger[key] = child.__trigger[key];
  13. }
  14. trigger.name = prefix + funcName;
  15. trigger.entryPoint = trigger.name.replace(/-/g, ".");
  16. triggers.push(trigger);
  17. }
  18. else if (typeof child === "object" && child !== null) {
  19. extractTriggers(child, triggers, prefix + funcName + "-");
  20. }
  21. }
  22. };
  23. module.exports = extractTriggers;