-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
31 lines (23 loc) · 829 Bytes
/
Copy pathindex.ts
File metadata and controls
31 lines (23 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import fs from 'fs'
import YAML from 'yaml'
import "./workflow";
import { WorkflowParser } from "./workflow/parser";
import { WorkflowRunner } from "./workflow/runner";
import SimpleLogger from "simple-node-logger";
const log = SimpleLogger.createSimpleLogger(
{
level: "error",
}
);
// const file = fs.readFileSync('./samples/fetchAndPrint.yml', 'utf8')
const file = fs.readFileSync('./samples/mathAndFork.yml', 'utf8')
const workflowDefinition = YAML.parse(file)
const wf = WorkflowParser.parse(workflowDefinition);
const runner = new WorkflowRunner(wf);
runner.onBlockFinished = (block, result) => {
log.info(`Block "${block.id}" finished with result: ${JSON.stringify(result)}`);
};
runner.run().then(result => {
log.info("Workflow ended.");
log.info(JSON.stringify(result, null, 2));
});