forked from SamVerschueren/listr-update-renderer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
86 lines (82 loc) · 1.68 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
77
78
79
80
81
82
83
84
85
86
'use strict';
const Observable = require('zen-observable');
const logSymbols = require('log-symbols');
const delay = require('delay');
const Listr = require('listr');
const renderer = require('.');
const tasks = new Listr([
{
title: 'Git',
task: () => {
return new Listr([
{
title: 'Checking git status',
task: () => {
return new Observable(observer => {
observer.next('foo');
delay(2000)
.then(() => {
observer.next('bar');
return delay(2000);
})
.then(() => {
observer.next(0);
return delay(500);
})
.then(() => {
observer.next(1);
return delay(500);
})
.then(() => {
observer.next({hello: 'world'});
return delay(500);
})
.then(() => {
observer.next('');
return delay(500);
})
.then(() => {
observer.complete();
});
});
}
},
{
title: 'Checking remote history',
task: () => delay(2000)
}
], {concurrent: true});
}
},
{
title: 'Install npm dependencies',
task: () => delay(2000)
},
{
title: 'Run tests',
task: () => delay(2000).then(() => {
return new Observable(observer => {
observer.next('clinton && xo && ava');
delay(2000)
.then(() => {
observer.next(`${logSymbols.success} 7 passed`);
return delay(2000);
})
.then(() => {
observer.complete();
});
});
})
},
{
title: 'Publish package',
task: () => delay(1000).then(() => {
throw new Error('Package name already exists');
})
}
], {
renderer
});
tasks.run().catch(error => {
console.error(error.message);
});