Skip to content

Commit ce214cb

Browse files
committed
Adds '--cls' option to clear screen between watch runs
1 parent 024de32 commit ce214cb

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/cli.js

+7
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ const FLAGS = {
9191
description: 'Re-run tests when files change',
9292
type: 'boolean',
9393
},
94+
cls: {
95+
alias: 'C',
96+
coerce: coerceLastValue,
97+
description: 'Clears the screen between test runs',
98+
type: 'boolean',
99+
},
94100
};
95101

96102
export default async function loadCli() { // eslint-disable-line complexity
@@ -465,6 +471,7 @@ export default async function loadCli() { // eslint-disable-line complexity
465471
reportStream: process.stdout,
466472
stdStream: process.stderr,
467473
watching: argv.watch,
474+
cls: argv.cls,
468475
});
469476
}
470477

lib/reporters/default.js

+6
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ export default class Reporter {
7373
stdStream,
7474
projectDir,
7575
watching,
76+
cls,
7677
durationThreshold,
7778
}) {
7879
this.extensions = extensions;
7980
this.reportStream = reportStream;
8081
this.stdStream = stdStream;
8182
this.watching = watching;
83+
this.cls = cls;
8284
this.relativeFile = file => {
8385
if (file.startsWith('file://')) {
8486
file = fileURLToPath(file);
@@ -128,6 +130,10 @@ export default class Reporter {
128130
}
129131

130132
startRun(plan) {
133+
if (this.cls) {
134+
this.lineWriter.write('\x1b[2J\x1b[H\x1b[3J');
135+
}
136+
131137
if (plan.bailWithoutReporting) {
132138
return;
133139
}

0 commit comments

Comments
 (0)