-
Notifications
You must be signed in to change notification settings - Fork 1
/
messages.js
35 lines (30 loc) · 852 Bytes
/
messages.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
const ora = require('ora');
const current = ora();
const start = ({ indent, spinner, color, prefixText, text }) => {
if (indent) current.indent = indent;
if (spinner) current.spinner = spinner;
if (color) current.color = color;
if (prefixText) current.prefixText = prefixText;
current.start(text);
};
const end = ({ type, text, symbol, prefixText }) => {
switch (type) {
case 'info':
current.info(text);
break;
case 'warn':
current.warn(text);
break;
case 'fail':
current.fail(text);
break;
case 'succeed':
current.succeed(text);
break;
default:
current.stopAndPersist({ symbol, prefixText, text });
}
};
const success = text => end({ type: 'succeed', text });
const fail = text => end({ type: 'fail', text });
module.exports = { start, end, success, fail };