Skip to content

Commit

Permalink
fix: broken enquirer in listr2 (#636)
Browse files Browse the repository at this point in the history
Refs: listr2/listr2#631
Fixes: #603
  • Loading branch information
XadillaX authored Jun 22, 2022
1 parent 14c4627 commit 460b50d
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 9 deletions.
7 changes: 6 additions & 1 deletion lib/update-v8/applyNodeChanges.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'node:path';

import Enquirer from 'enquirer';
import { Listr } from 'listr2';

import {
Expand All @@ -22,7 +23,11 @@ export default function applyNodeChanges() {
task: async(ctx) => {
const v8Version = await getNodeV8Version(ctx.nodeDir);
const list = filterForVersion(nodeChanges, v8Version);
return new Listr(list.map((change) => change.task()));
return new Listr(list.map((change) => change.task()), {
injectWrapper: {
enquirer: new Enquirer()
}
});
}
};
}
Expand Down
19 changes: 16 additions & 3 deletions lib/update-v8/backport.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
promises as fs
} from 'node:fs';

import Enquirer from 'enquirer';
import inquirer from 'inquirer';
import { Listr } from 'listr2';

Expand Down Expand Up @@ -50,7 +51,11 @@ export function doBackport(options) {
return {
title: 'V8 commit backport',
task: () => {
return new Listr(todo);
return new Listr(todo, {
injectWrapper: {
enquirer: new Enquirer()
}
});
}
};
};
Expand Down Expand Up @@ -168,7 +173,11 @@ function applyAndCommitPatches() {
return {
title: 'Apply and commit patches to deps/v8',
task: (ctx) => {
return new Listr(ctx.patches.map(applyPatchTask));
return new Listr(ctx.patches.map(applyPatchTask), {
injectWrapper: {
enquirer: new Enquirer()
}
});
}
};
}
Expand All @@ -191,7 +200,11 @@ function applyPatchTask(patch) {
}
}
todo.push(commitPatch(patch));
return new Listr(todo);
return new Listr(todo, {
injectWrapper: {
enquirer: new Enquirer()
}
});
}
};
}
Expand Down
11 changes: 10 additions & 1 deletion lib/update-v8/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Enquirer from 'enquirer';
import { Listr } from 'listr2';

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

/**
* Get the listr2 options.
* @param {{ verbose?: boolean }} options The original options.
* @return {import('listr2').ListrOptions} The listr2 options.
*/
function getOptions(opts) {
return {
renderer: opts.verbose ? 'verbose' : 'default'
renderer: opts.verbose ? 'verbose' : 'default',
injectWrapper: {
enquirer: new Enquirer()
}
};
}
7 changes: 6 additions & 1 deletion lib/update-v8/majorUpdate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'node:path';
import { promises as fs } from 'node:fs';

import Enquirer from 'enquirer';
import { execa } from 'execa';
import { Listr } from 'listr2';

Expand Down Expand Up @@ -28,7 +29,11 @@ export default function majorUpdate() {
addDepsV8(),
updateV8Deps(),
applyNodeChanges()
]);
], {
injectWrapper: {
enquirer: new Enquirer()
}
});
}
};
};
Expand Down
7 changes: 6 additions & 1 deletion lib/update-v8/minorUpdate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'node:path';
import { promises as fs } from 'node:fs';

import Enquirer from 'enquirer';
import { execa } from 'execa';
import { Listr } from 'listr2';

Expand All @@ -14,7 +15,11 @@ export default function minorUpdate() {
getCurrentV8Version(),
getLatestV8Version(),
doMinorUpdate()
]);
], {
injectWrapper: {
enquirer: new Enquirer()
}
});
}
};
};
Expand Down
7 changes: 6 additions & 1 deletion lib/update-v8/updateV8Clone.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { promises as fs } from 'node:fs';

import Enquirer from 'enquirer';
import { execa } from 'execa';
import { Listr } from 'listr2';

Expand All @@ -9,7 +10,11 @@ export default function updateV8Clone() {
return {
title: 'Update local V8 clone',
task: () => {
return new Listr([fetchOrigin(), createClone()]);
return new Listr([fetchOrigin(), createClone()], {
injectWrapper: {
enquirer: new Enquirer()
}
});
}
};
};
Expand Down
7 changes: 6 additions & 1 deletion lib/update-v8/updateVersionNumbers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'node:path';
import { promises as fs } from 'node:fs';

import Enquirer from 'enquirer';
import { Listr } from 'listr2';

import { getNodeV8Version } from './util.js';
Expand All @@ -9,7 +10,11 @@ export default function updateVersionNumbers() {
return {
title: 'Update version numbers',
task: () => {
return new Listr([resetEmbedderString(), bumpNodeModule()]);
return new Listr([resetEmbedderString(), bumpNodeModule()], {
injectWrapper: {
enquirer: new Enquirer()
}
});
}
};
};
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"cheerio": "^1.0.0-rc.10",
"clipboardy": "^3.0.0",
"core-validate-commit": "^3.16.0",
"enquirer": "^2.3.6",
"execa": "^6.1.0",
"figures": "^4.0.1",
"form-data": "^4.0.0",
Expand Down

0 comments on commit 460b50d

Please sign in to comment.