Skip to content

Commit 13376ce

Browse files
perakerberghaoqunjiang
authored andcommitted
Replace chalk.reset with stripAnsi in @vue/cli-shared-utils/lib/logger.js (#4842)
* Replace chalk.reset with stripAnsi When logging multi-line logs, the logger uses chalk.reset in order to get the length of the tag for the log. This is to achieve an indented layout of multi-line logs. chalk.reset only replaces styles such as bold and italic, not color. When the tag contains colors, the result is not pretty. Replacing with stripAnsi gets the intended result. * Adds reference to strip-ansi * Removes misplaces comma from package.json * Removes extraneous semicolon
1 parent ba9596d commit 13376ce

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const chalk = require('chalk')
2+
const stripAnsi = require('strip-ansi')
23
const readline = require('readline')
34
const padStart = require('string.prototype.padstart')
45
const EventEmitter = require('events')
@@ -19,7 +20,7 @@ const format = (label, msg) => {
1920
return msg.split('\n').map((line, i) => {
2021
return i === 0
2122
? `${label} ${line}`
22-
: padStart(line, chalk.reset(label).length)
23+
: padStart(line, stripAnsi(label).length)
2324
}).join('\n')
2425
}
2526

packages/@vue/cli-shared-utils/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"request": "^2.87.0",
3232
"request-promise-native": "^1.0.8",
3333
"semver": "^6.1.0",
34-
"string.prototype.padstart": "^3.0.0"
34+
"string.prototype.padstart": "^3.0.0",
35+
"strip-ansi" : "^6.0.0"
3536
},
3637
"publishConfig": {
3738
"access": "public"

0 commit comments

Comments
 (0)