mirror of
https://gitee.com/WeBank/fes.js.git
synced 2024-12-02 03:37:57 +08:00
36 lines
645 B
JavaScript
36 lines
645 B
JavaScript
/* eslint import/no-extraneous-dependencies: 0 */
|
|
import chalk from 'chalk';
|
|
|
|
const colors = [
|
|
'red',
|
|
'green',
|
|
'yellow',
|
|
'blue',
|
|
'magenta',
|
|
'cyan',
|
|
'gray',
|
|
'redBright',
|
|
'greenBright',
|
|
'yellowBright',
|
|
'blueBright',
|
|
'magentaBright',
|
|
'cyanBright',
|
|
];
|
|
|
|
let index = 0;
|
|
const cache = {};
|
|
|
|
export default function (pkg) {
|
|
if (!cache[pkg]) {
|
|
const color = colors[index];
|
|
const str = chalk[color].bold(pkg);
|
|
cache[pkg] = str;
|
|
if (index === colors.length - 1) {
|
|
index = 0;
|
|
} else {
|
|
index += 1;
|
|
}
|
|
}
|
|
return cache[pkg];
|
|
}
|