Skip to content

Commit 460b50d

Browse files
authored
fix: broken enquirer in listr2 (#636)
Refs: listr2/listr2#631 Fixes: #603
1 parent 14c4627 commit 460b50d

8 files changed

+57
-9
lines changed

lib/update-v8/applyNodeChanges.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from 'node:path';
22

3+
import Enquirer from 'enquirer';
34
import { Listr } from 'listr2';
45

56
import {
@@ -22,7 +23,11 @@ export default function applyNodeChanges() {
2223
task: async(ctx) => {
2324
const v8Version = await getNodeV8Version(ctx.nodeDir);
2425
const list = filterForVersion(nodeChanges, v8Version);
25-
return new Listr(list.map((change) => change.task()));
26+
return new Listr(list.map((change) => change.task()), {
27+
injectWrapper: {
28+
enquirer: new Enquirer()
29+
}
30+
});
2631
}
2732
};
2833
}

lib/update-v8/backport.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
promises as fs
44
} from 'node:fs';
55

6+
import Enquirer from 'enquirer';
67
import inquirer from 'inquirer';
78
import { Listr } from 'listr2';
89

@@ -50,7 +51,11 @@ export function doBackport(options) {
5051
return {
5152
title: 'V8 commit backport',
5253
task: () => {
53-
return new Listr(todo);
54+
return new Listr(todo, {
55+
injectWrapper: {
56+
enquirer: new Enquirer()
57+
}
58+
});
5459
}
5560
};
5661
};
@@ -168,7 +173,11 @@ function applyAndCommitPatches() {
168173
return {
169174
title: 'Apply and commit patches to deps/v8',
170175
task: (ctx) => {
171-
return new Listr(ctx.patches.map(applyPatchTask));
176+
return new Listr(ctx.patches.map(applyPatchTask), {
177+
injectWrapper: {
178+
enquirer: new Enquirer()
179+
}
180+
});
172181
}
173182
};
174183
}
@@ -191,7 +200,11 @@ function applyPatchTask(patch) {
191200
}
192201
}
193202
todo.push(commitPatch(patch));
194-
return new Listr(todo);
203+
return new Listr(todo, {
204+
injectWrapper: {
205+
enquirer: new Enquirer()
206+
}
207+
});
195208
}
196209
};
197210
}

lib/update-v8/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Enquirer from 'enquirer';
12
import { Listr } from 'listr2';
23

34
import { checkOptions, doBackport } from './backport.js';
@@ -33,8 +34,16 @@ export async function backport(options) {
3334
return tasks.run(options);
3435
};
3536

37+
/**
38+
* Get the listr2 options.
39+
* @param {{ verbose?: boolean }} options The original options.
40+
* @return {import('listr2').ListrOptions} The listr2 options.
41+
*/
3642
function getOptions(opts) {
3743
return {
38-
renderer: opts.verbose ? 'verbose' : 'default'
44+
renderer: opts.verbose ? 'verbose' : 'default',
45+
injectWrapper: {
46+
enquirer: new Enquirer()
47+
}
3948
};
4049
}

lib/update-v8/majorUpdate.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from 'node:path';
22
import { promises as fs } from 'node:fs';
33

4+
import Enquirer from 'enquirer';
45
import { execa } from 'execa';
56
import { Listr } from 'listr2';
67

@@ -28,7 +29,11 @@ export default function majorUpdate() {
2829
addDepsV8(),
2930
updateV8Deps(),
3031
applyNodeChanges()
31-
]);
32+
], {
33+
injectWrapper: {
34+
enquirer: new Enquirer()
35+
}
36+
});
3237
}
3338
};
3439
};

lib/update-v8/minorUpdate.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from 'node:path';
22
import { promises as fs } from 'node:fs';
33

4+
import Enquirer from 'enquirer';
45
import { execa } from 'execa';
56
import { Listr } from 'listr2';
67

@@ -14,7 +15,11 @@ export default function minorUpdate() {
1415
getCurrentV8Version(),
1516
getLatestV8Version(),
1617
doMinorUpdate()
17-
]);
18+
], {
19+
injectWrapper: {
20+
enquirer: new Enquirer()
21+
}
22+
});
1823
}
1924
};
2025
};

lib/update-v8/updateV8Clone.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { promises as fs } from 'node:fs';
22

3+
import Enquirer from 'enquirer';
34
import { execa } from 'execa';
45
import { Listr } from 'listr2';
56

@@ -9,7 +10,11 @@ export default function updateV8Clone() {
910
return {
1011
title: 'Update local V8 clone',
1112
task: () => {
12-
return new Listr([fetchOrigin(), createClone()]);
13+
return new Listr([fetchOrigin(), createClone()], {
14+
injectWrapper: {
15+
enquirer: new Enquirer()
16+
}
17+
});
1318
}
1419
};
1520
};

lib/update-v8/updateVersionNumbers.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from 'node:path';
22
import { promises as fs } from 'node:fs';
33

4+
import Enquirer from 'enquirer';
45
import { Listr } from 'listr2';
56

67
import { getNodeV8Version } from './util.js';
@@ -9,7 +10,11 @@ export default function updateVersionNumbers() {
910
return {
1011
title: 'Update version numbers',
1112
task: () => {
12-
return new Listr([resetEmbedderString(), bumpNodeModule()]);
13+
return new Listr([resetEmbedderString(), bumpNodeModule()], {
14+
injectWrapper: {
15+
enquirer: new Enquirer()
16+
}
17+
});
1318
}
1419
};
1520
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"cheerio": "^1.0.0-rc.10",
3838
"clipboardy": "^3.0.0",
3939
"core-validate-commit": "^3.16.0",
40+
"enquirer": "^2.3.6",
4041
"execa": "^6.1.0",
4142
"figures": "^4.0.1",
4243
"form-data": "^4.0.0",

0 commit comments

Comments
 (0)