Skip to content

Commit

Permalink
Replace chalk.reset with stripAnsi in @vue/cli-shared-utils/lib/logge…
Browse files Browse the repository at this point in the history
…r.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
  • Loading branch information
perakerberg authored and sodatea committed Nov 27, 2019
1 parent ba9596d commit 13376ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/@vue/cli-shared-utils/lib/logger.js
@@ -1,4 +1,5 @@
const chalk = require('chalk')
const stripAnsi = require('strip-ansi')
const readline = require('readline')
const padStart = require('string.prototype.padstart')
const EventEmitter = require('events')
Expand All @@ -19,7 +20,7 @@ const format = (label, msg) => {
return msg.split('\n').map((line, i) => {
return i === 0
? `${label} ${line}`
: padStart(line, chalk.reset(label).length)
: padStart(line, stripAnsi(label).length)
}).join('\n')
}

Expand Down
3 changes: 2 additions & 1 deletion packages/@vue/cli-shared-utils/package.json
Expand Up @@ -31,7 +31,8 @@
"request": "^2.87.0",
"request-promise-native": "^1.0.8",
"semver": "^6.1.0",
"string.prototype.padstart": "^3.0.0"
"string.prototype.padstart": "^3.0.0",
"strip-ansi" : "^6.0.0"
},
"publishConfig": {
"access": "public"
Expand Down

0 comments on commit 13376ce

Please sign in to comment.