-
-
Notifications
You must be signed in to change notification settings - Fork 270
/
example.js
76 lines (62 loc) · 1.58 KB
/
example.js
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
import process from 'node:process';
import chalk from 'chalk';
import logSymbols from 'log-symbols';
import ora from './index.js';
const spinner = ora({
discardStdin: false,
text: 'Loading unicorns, not discarding stdin',
spinner: process.argv[2],
});
const spinnerDiscardingStdin = ora({
text: 'Loading unicorns',
spinner: process.argv[2],
});
spinnerDiscardingStdin.start();
setTimeout(() => {
spinnerDiscardingStdin.succeed();
}, 1000);
setTimeout(() => {
spinnerDiscardingStdin.start();
}, 2000);
setTimeout(() => {
spinnerDiscardingStdin.succeed();
spinner.start();
}, 3000);
setTimeout(() => {
spinner.color = 'yellow';
spinner.text = `Loading ${chalk.red('rainbows')}`;
}, 4000);
setTimeout(() => {
spinner.color = 'green';
spinner.indent = 2;
spinner.text = 'Loading with indent';
}, 5000);
setTimeout(() => {
spinner.indent = 0;
spinner.spinner = 'moon';
spinner.text = 'Loading with different spinners';
}, 6000);
setTimeout(() => {
spinner.prefixText = chalk.dim('[info]');
spinner.spinner = 'dots';
spinner.text = 'Loading with prefix text';
}, 8000);
setTimeout(() => {
spinner.prefixText = '';
spinner.suffixText = chalk.dim('[info]');
spinner.text = 'Loading with suffix text';
}, 10_000);
setTimeout(() => {
spinner.prefixText = chalk.dim('[info]');
spinner.suffixText = chalk.dim('[info]');
spinner.text = 'Loading with prefix and suffix text';
}, 12_000);
setTimeout(() => {
spinner.stopAndPersist({
prefixText: '',
suffixText: '',
symbol: logSymbols.info,
text: 'Stopping with different text!',
});
}, 14_000);
// $ node example.js nameOfSpinner