forked from vuejs/vue-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclearConsole.js
34 lines (29 loc) Β· 1.1 KB
/
clearConsole.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const chalk = require('chalk')
const semver = require('semver')
const getVersions = require('./getVersions')
const { clearConsole } = require('@vue/cli-shared-utils')
exports.generateTitle = async function (checkUpdate) {
const { current, latest } = await getVersions()
let title = chalk.bold.blue(`Vue CLI v${current}`)
if (process.env.VUE_CLI_TEST) {
title += ' ' + chalk.blue.bold('TEST')
}
if (process.env.VUE_CLI_DEBUG) {
title += ' ' + chalk.magenta.bold('DEBUG')
}
if (checkUpdate && semver.gt(latest, current)) {
if (process.env.VUE_CLI_API_MODE) {
title += chalk.green(` ποΈ Update available: ${latest}`)
} else {
title += chalk.green(`
βββββββββββββββββββββ${`β`.repeat(latest.length)}βββ
β Update available: ${latest} β
βββββββββββββββββββββ${`β`.repeat(latest.length)}βββ`)
}
}
return title
}
exports.clearConsole = async function clearConsoleWithTitle (checkUpdate) {
const title = await exports.generateTitle(checkUpdate)
clearConsole(title)
}