-
-
Notifications
You must be signed in to change notification settings - Fork 128
/
task-wrapper.js
110 lines (95 loc) · 1.82 KB
/
task-wrapper.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import {serial as test} from 'ava';
import Listr from '..';
import SimpleRenderer from './fixtures/simple-renderer';
import {testOutput} from './fixtures/utils';
test('changing the title during task execution', async t => {
const list = new Listr([
{
title: 'foo',
task: (ctx, task) => {
task.title = 'foo bar';
}
}
], {renderer: SimpleRenderer});
testOutput(t, [
'foo [started]',
'foo bar [title changed]',
'foo bar [completed]',
'done'
]);
await list.run();
});
test('changing the output during task execution', async t => {
const list = new Listr([
{
title: 'foo',
task: (ctx, task) => {
task.output = 'some output';
}
}
], {renderer: SimpleRenderer});
testOutput(t, [
'foo [started]',
'> some output',
'foo [completed]',
'done'
]);
await list.run();
});
test('skip task during task execution with no message', async t => {
const list = new Listr([
{
title: 'foo',
task: (ctx, task) => {
task.skip();
}
}
], {renderer: SimpleRenderer});
testOutput(t, [
'foo [started]',
'foo [skipped]',
'done'
]);
await list.run();
});
test('skip task during task execution with message', async t => {
const list = new Listr([
{
title: 'foo',
task: (ctx, task) => {
task.skip('foo bar');
}
}
], {renderer: SimpleRenderer});
testOutput(t, [
'foo [started]',
'foo [skipped]',
'> foo bar',
'done'
]);
await list.run();
});
test('skip subtask', async t => {
const list = new Listr([
{
title: 'foo',
task: () => new Listr([
{
title: 'bar',
task: (ctx, task) => {
task.skip('foo bar');
}
}
], {renderer: SimpleRenderer})
}
], {renderer: SimpleRenderer});
testOutput(t, [
'foo [started]',
'bar [started]',
'bar [skipped]',
'> foo bar',
'foo [completed]',
'done'
]);
await list.run();
});