Skip to content
This repository was archived by the owner on Jul 27, 2021. It is now read-only.

Commit 4b6f841

Browse files
timneutkensgeowarin
authored andcommitted
Preserve user command history (#23)
1 parent 62a7742 commit 4b6f841

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

_sandbox/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export default class MyComponent extends React.Component {
66
render() {
77
return <div>Hello</div>
88
}
9-
}
9+
}

src/output.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const colors = require('./utils/colors');
44
const chalk = require('chalk');
55
const stringLength = require('string-length');
6+
const readline = require('readline');
67

78
class Debugger {
89

@@ -74,8 +75,12 @@ class Debugger {
7475
}
7576

7677
clearConsole () {
77-
if (!this.capturing && this.enabled) {
78-
process.stdout.write(process.platform === 'win32' ? '\x1Bc' : '\x1B[2J\x1B[3J\x1B[H');
78+
if (!this.capturing && this.enabled && process.stdout.isTTY) {
79+
// Fill screen with blank lines. Then move to 0 (beginning of visible part) and clear it
80+
const blank = '\n'.repeat(process.stdout.rows)
81+
console.log(blank)
82+
readline.cursorTo(process.stdout, 0, 0)
83+
readline.clearScreenDown(process.stdout)
7984
}
8085
}
8186

0 commit comments

Comments
 (0)