-
-
Notifications
You must be signed in to change notification settings - Fork 109
/
example.js
76 lines (70 loc) · 1.48 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 {Observable} from 'rxjs';
import logSymbols from 'log-symbols';
import delay from 'delay';
import Listr from '.';
const renderer = process.argv[2];
const tasks = new Listr([
{
title: 'Git',
task: () => new Listr([
{
title: 'Checking git status',
task: () => new Observable(observer => {
observer.next('foo');
delay(2000)
.then(() => {
observer.next('bar');
return delay(2000);
})
.then(() => {
observer.complete();
});
}),
},
{
title: 'Checking remote history',
task: () => delay(2000),
},
], {concurrent: true}),
},
{
title: 'Install dependencies with Yarn',
task: (ctx, task) => delay(2000)
.then(() => {
ctx.yarn = false;
task.title = `${task.title} (or not)`;
task.skip('Yarn not available');
}),
},
{
title: 'Install dependencies with npm',
enabled: ctx => ctx.yarn === false,
task: () => delay(3000),
},
{
title: 'Run tests',
task: () => delay(2000).then(() => 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);
});