| 43 | const result: LazyHandler[] = [] |
| 44 | |
| 45 | function add(node: Spec.Any, value: RuntimeHandlers) { |
| 46 | if (typeof value === "function") { |
| 47 | result.push({ spec: node.spec, load: value as () => Promise<{ default: RuntimeHandler }> }) |
| 48 | return |
| 49 | } |
| 50 | if (value.$) result.push({ spec: node.spec, load: value.$ as () => Promise<{ default: RuntimeHandler }> }) |
| 51 | for (const [name, child] of Object.entries(node.commands)) add(child, value[name] as RuntimeHandlers) |
| 52 | } |
| 53 | |
| 54 | add(root, handlers as RuntimeHandlers) |
| 55 | return result |