1 | # tty-aware-progress
|
2 | [](https://travis-ci.org/bkniffler/tty-aware-progress)
|
3 |
|
4 | The excellent `progress` package from npm will unfortunately ignore non-TTY environments like CI (circle-ci, travis, etc). This package uses `progress`, but in case of non-TTY, the progress will be output as rolling logs.
|
5 |
|
6 | ## Install
|
7 |
|
8 | ```bash
|
9 | npm install tty-aware-progress
|
10 | # or
|
11 | yarn add tty-aware-progress
|
12 | ```
|
13 |
|
14 | ## Use
|
15 |
|
16 | `tty-aware-progress` will only need the total number of expected ticks like shown below. It returns a function that emits progress.
|
17 |
|
18 | ```js
|
19 | import createProgress from 'tty-aware-progress';
|
20 |
|
21 | const progress = createProgress(100);
|
22 | for (var i = 0; i < 100; i++) {
|
23 | progress();
|
24 | }
|
25 |
|
26 | // OR
|
27 |
|
28 | const progress = createProgress(100);
|
29 | for (var i = 0; i < 10; i++) {
|
30 | progress(10);
|
31 | }
|
32 | ```
|