Total Complexity | 4 |
Complexity/F | 0 |
Lines of Code | 50 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | "use strict"; |
||
2 | import chalk from "chalk"; |
||
3 | |||
4 | var states = { |
||
5 | active: "active", |
||
6 | done: "done", |
||
7 | fail: "fail", |
||
8 | }; |
||
9 | |||
10 | var loader = function () { |
||
11 | (function () { |
||
12 | var P = ["\\", "|", "/", "-"]; |
||
13 | var x = 0; |
||
14 | return setInterval(function () { |
||
15 | process.stdout.write("\r" + P[x++]); |
||
16 | x &= 3; |
||
17 | }, 250); |
||
18 | })(); |
||
19 | }; |
||
20 | |||
21 | var defaultSettings = { |
||
22 | width: 55, |
||
23 | prefix: ">>> ", |
||
24 | write: process.stdout.write.bind(process.stdout), |
||
25 | formatStatus: function (statusLabel, state) { |
||
26 | if (!statusLabel) { |
||
27 | return ""; |
||
28 | } |
||
29 | |||
30 | if (state === states.active) { |
||
31 | return chalk.yellow(statusLabel); |
||
32 | } |
||
33 | |||
34 | if (state === states.done) { |
||
35 | return chalk.green(statusLabel); |
||
36 | } |
||
37 | |||
38 | if (state === states.fail) { |
||
39 | return chalk.red(statusLabel); |
||
40 | } |
||
41 | |||
42 | return statusLabel; |
||
43 | }, |
||
44 | }; |
||
45 | |||
46 | export = { |
||
47 | state: states, |
||
48 | defaultSettings: defaultSettings, |
||
49 | }; |
||
50 |