2021-08-07 15:43:24 +08:00
|
|
|
/* eslint import/no-extraneous-dependencies: 0 */
|
2022-04-10 17:43:49 +08:00
|
|
|
import chalk from 'chalk';
|
2021-08-07 15:43:24 +08:00
|
|
|
|
|
|
|
const colors = [
|
|
|
|
'red',
|
|
|
|
'green',
|
|
|
|
'yellow',
|
|
|
|
'blue',
|
|
|
|
'magenta',
|
|
|
|
'cyan',
|
|
|
|
'gray',
|
|
|
|
'redBright',
|
|
|
|
'greenBright',
|
|
|
|
'yellowBright',
|
|
|
|
'blueBright',
|
|
|
|
'magentaBright',
|
2022-03-26 14:58:01 +08:00
|
|
|
'cyanBright',
|
2021-08-07 15:43:24 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
let index = 0;
|
|
|
|
const cache = {};
|
|
|
|
|
2022-04-10 17:43:49 +08:00
|
|
|
export default function (pkg) {
|
2021-08-07 15:43:24 +08:00
|
|
|
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];
|
2022-04-10 17:43:49 +08:00
|
|
|
}
|