| 15 | } |
| 16 | |
| 17 | export async function loadWorkflows(src: string) { |
| 18 | /** The set of workflows which can be executed. */ |
| 19 | const filteredWorkflows: {[key: string]: Workflow} = {}; |
| 20 | /** The workflow configuration file content as a string. */ |
| 21 | const rawWorkflows = await readFile(src, {encoding: 'utf-8'}); |
| 22 | /** The object parsed from the workflow configuration file, holding the workflow configurations. */ |
| 23 | const workflows = parse(rawWorkflows).workflows as {[key: string]: Workflow}; |
| 24 | |
| 25 | // Remove any workflow which is marked as disabled. |
| 26 | for (const [name, workflow] of Object.entries(workflows)) { |
| 27 | if (workflow.disabled !== true) { |
| 28 | filteredWorkflows[name] = workflow; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | return filteredWorkflows; |
| 33 | } |