chalk/examples/screenshot.js

19 lines
409 B
JavaScript
Raw Normal View History

import process from 'node:process';
2021-04-16 15:23:29 +07:00
import styles from 'ansi-styles';
import chalk from '../source/index.js';
2016-10-26 12:58:01 +07:00
2017-05-21 23:28:38 +07:00
// Generates screenshot
2017-06-29 16:00:51 -07:00
for (const key of Object.keys(styles)) {
2020-04-02 15:56:21 +08:00
let returnValue = key;
2016-10-26 12:58:01 +07:00
if (key === 'reset' || key === 'hidden' || key === 'grey') {
continue;
}
if (/^bg[^B]/.test(key)) {
2020-04-02 15:56:21 +08:00
returnValue = chalk.black(returnValue);
2016-10-26 12:58:01 +07:00
}
2020-04-02 15:56:21 +08:00
process.stdout.write(chalk[key](returnValue) + ' ');
2016-10-26 12:58:01 +07:00
}