chalk/examples/screenshot.js

19 lines
381 B
JavaScript
Raw Normal View History

2016-10-26 12:58:01 +07:00
'use strict';
2017-06-29 16:00:51 -07:00
const styles = require('ansi-styles');
2019-07-12 09:40:23 +03:00
const chalk = require('..');
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
}