executionConditionCount.js 557 B

1234567891011121314151617181920212223242526272829303132
  1. function nonEmptyList (list) {
  2. return Array.isArray(list) && list.length > 0
  3. }
  4. export function countExecutionConditions (action) {
  5. if (!action) {
  6. return 0
  7. }
  8. let count = 1
  9. if (action.execOnStartup) {
  10. count++
  11. }
  12. if (nonEmptyList(action.execOnCron)) {
  13. count++
  14. }
  15. if (nonEmptyList(action.execOnFileCreatedInDir)) {
  16. count++
  17. }
  18. if (nonEmptyList(action.execOnFileChangedInDir)) {
  19. count++
  20. }
  21. if (action.execOnCalendarFile) {
  22. count++
  23. }
  24. if (nonEmptyList(action.execOnWebhooks)) {
  25. count++
  26. }
  27. return count
  28. }