UNPKG

1.86 kBJavaScriptView Raw
1var colors = require('../lib/index');
2
3console.log('First some yellow text'.yellow);
4
5console.log('Underline that text'.yellow.underline);
6
7console.log('Make it bold and red'.red.bold);
8
9console.log(('Double Raindows All Day Long').rainbow);
10
11console.log('Drop the bass'.trap);
12
13console.log('DROP THE RAINBOW BASS'.trap.rainbow);
14
15// styles not widely supported
16console.log('Chains are also cool.'.bold.italic.underline.red);
17
18// styles not widely supported
19console.log('So '.green + 'are'.underline + ' ' + 'inverse'.inverse
20 + ' styles! '.yellow.bold);
21console.log('Zebras are so fun!'.zebra);
22
23//
24// Remark: .strikethrough may not work with Mac OS Terminal App
25//
26console.log('This is ' + 'not'.strikethrough + ' fun.');
27
28console.log('Background color attack!'.black.bgWhite);
29console.log('Use random styles on everything!'.random);
30console.log('America, Heck Yeah!'.america);
31
32
33console.log('Setting themes is useful');
34
35//
36// Custom themes
37//
38console.log('Generic logging theme as JSON'.green.bold.underline);
39// Load theme with JSON literal
40colors.setTheme({
41 silly: 'rainbow',
42 input: 'grey',
43 verbose: 'cyan',
44 prompt: 'grey',
45 info: 'green',
46 data: 'grey',
47 help: 'cyan',
48 warn: 'yellow',
49 debug: 'blue',
50 error: 'red',
51});
52
53// outputs red text
54console.log('this is an error'.error);
55
56// outputs yellow text
57console.log('this is a warning'.warn);
58
59// outputs grey text
60console.log('this is an input'.input);
61
62console.log('Generic logging theme as file'.green.bold.underline);
63
64// Load a theme from file
65try {
66 colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));
67} catch (err) {
68 console.log(err);
69}
70
71// outputs red text
72console.log('this is an error'.error);
73
74// outputs yellow text
75console.log('this is a warning'.warn);
76
77// outputs grey text
78console.log('this is an input'.input);
79
80// console.log("Don't summon".zalgo)
81