summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/colors/examples/normal-usage.js
blob: cc8d05ff4f23a43fe3b3aa5614e09c8966f2f9b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var colors = require('../lib/index');

console.log('First some yellow text'.yellow);

console.log('Underline that text'.yellow.underline);

console.log('Make it bold and red'.red.bold);

console.log(('Double Raindows All Day Long').rainbow);

console.log('Drop the bass'.trap);

console.log('DROP THE RAINBOW BASS'.trap.rainbow);

// styles not widely supported
console.log('Chains are also cool.'.bold.italic.underline.red);

// styles not widely supported
console.log('So '.green + 'are'.underline + ' ' + 'inverse'.inverse
  + ' styles! '.yellow.bold);
console.log('Zebras are so fun!'.zebra);

//
// Remark: .strikethrough may not work with Mac OS Terminal App
//
console.log('This is ' + 'not'.strikethrough + ' fun.');

console.log('Background color attack!'.black.bgWhite);
console.log('Use random styles on everything!'.random);
console.log('America, Heck Yeah!'.america);


console.log('Setting themes is useful');

//
// Custom themes
//
console.log('Generic logging theme as JSON'.green.bold.underline);
// Load theme with JSON literal
colors.setTheme({
  silly: 'rainbow',
  input: 'grey',
  verbose: 'cyan',
  prompt: 'grey',
  info: 'green',
  data: 'grey',
  help: 'cyan',
  warn: 'yellow',
  debug: 'blue',
  error: 'red',
});

// outputs red text
console.log('this is an error'.error);

// outputs yellow text
console.log('this is a warning'.warn);

// outputs grey text
console.log('this is an input'.input);

console.log('Generic logging theme as file'.green.bold.underline);

// Load a theme from file
try {
  colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));
} catch (err) {
  console.log(err);
}

// outputs red text
console.log('this is an error'.error);

// outputs yellow text
console.log('this is a warning'.warn);

// outputs grey text
console.log('this is an input'.input);

// console.log("Don't summon".zalgo)