Skip to content

Commit f1e77a5

Browse files
committed
Revert "refactor: use console.clear to clear the log (vuejs#5700)"
This reverts commit 7c2a36b. `console.clear` overrides the previous content on the screen, so it might cause confusion when users scrolls back.
1 parent 5634825 commit f1e77a5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/@vue/cli-shared-utils/lib/logger.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const chalk = require('chalk')
22
const stripAnsi = require('strip-ansi')
3+
const readline = require('readline')
34
const EventEmitter = require('events')
45

56
const { stopSpinner } = require('./spinner')
@@ -58,7 +59,10 @@ exports.error = (msg, tag = null) => {
5859

5960
exports.clearConsole = title => {
6061
if (process.stdout.isTTY) {
61-
console.clear()
62+
const blank = '\n'.repeat(process.stdout.rows)
63+
console.log(blank)
64+
readline.cursorTo(process.stdout, 0, 0)
65+
readline.clearScreenDown(process.stdout)
6266
if (title) {
6367
console.log(title)
6468
}

0 commit comments

Comments
 (0)