-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogress.ts
More file actions
33 lines (30 loc) · 961 Bytes
/
Copy pathprogress.ts
File metadata and controls
33 lines (30 loc) · 961 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
32
33
import { debug } from "codebase-stats-collector/dist/console/console.js";
import { SummaryDashboard } from "codebase-stats-collector/dist/dashboard/summary-dashboard.js";
import { ExpandedCommit } from "codebase-stats-collector/dist/interfaces.js";
import { Readable } from "stream";
export function setupProgressStream(
summaryDashboard: SummaryDashboard,
): Readable {
let commitsCounter = 0;
const commitsStream = new Readable({
objectMode: true,
read() {
// do nothing.
},
});
commitsStream.on("data", (commit: ExpandedCommit) => {
debug("Commit", commit);
commitsCounter += 1;
summaryDashboard.setCurrentProgress(commitsCounter, commit);
});
commitsStream.on("error", (err) => {
debug("error reading commits", { err });
});
commitsStream.on("end", () => {
debug("done reading commits", {});
});
commitsStream.on("close", () => {
debug("stream closed", {});
});
return commitsStream;
}