• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const { MathMax } = primordials;
3
4module.exports = async function* dot(source) {
5  let count = 0;
6  let columns = getLineLength();
7  for await (const { type } of source) {
8    if (type === 'test:pass') {
9      yield '.';
10    }
11    if (type === 'test:fail') {
12      yield 'X';
13    }
14    if ((type === 'test:fail' || type === 'test:pass') && ++count === columns) {
15      yield '\n';
16
17      // Getting again in case the terminal was resized.
18      columns = getLineLength();
19      count = 0;
20    }
21  }
22  yield '\n';
23};
24
25function getLineLength() {
26  return MathMax(process.stdout.columns ?? 20, 20);
27}
28