Skip to content

Commit

Permalink
Adds '--cls' option to clear screen between watch runs
Browse files Browse the repository at this point in the history
  • Loading branch information
colinta committed Nov 23, 2024
1 parent 024de32 commit 3f24214
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ const FLAGS = {
description: 'Re-run tests when files change',
type: 'boolean',
},
cls: {
alias: 'C',
coerce: coerceLastValue,
description: 'Clears the screen between test runs',
type: 'boolean',
},
};

export default async function loadCli() { // eslint-disable-line complexity
Expand Down Expand Up @@ -465,6 +471,7 @@ export default async function loadCli() { // eslint-disable-line complexity
reportStream: process.stdout,
stdStream: process.stderr,
watching: argv.watch,
cls: argv.cls,
});
}

Expand Down
6 changes: 6 additions & 0 deletions lib/reporters/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ export default class Reporter {
stdStream,
projectDir,
watching,
cls,
durationThreshold,
}) {
this.extensions = extensions;
this.reportStream = reportStream;
this.stdStream = stdStream;
this.watching = watching;
this.cls = cls;
this.relativeFile = file => {
if (file.startsWith('file://')) {
file = fileURLToPath(file);
Expand Down Expand Up @@ -128,6 +130,10 @@ export default class Reporter {
}

startRun(plan) {
if (this.cls) {
this.lineWriter.write('\x1b[2J\x1b[H\x1b[3J');

Check failure on line 134 in lib/reporters/default.js

View workflow job for this annotation

GitHub Actions / Lint source files

Use uppercase characters for the value of the escape sequence.

Check failure on line 134 in lib/reporters/default.js

View workflow job for this annotation

GitHub Actions / Lint source files

Use Unicode escapes instead of hexadecimal escapes.
}

if (plan.bailWithoutReporting) {
return;
}
Expand Down

0 comments on commit 3f24214

Please sign in to comment.