Skip to content

Commit

Permalink
fix: Listr2 custom renderer (#27189)
Browse files Browse the repository at this point in the history
no more subscribe method,
but rather event emitters
  • Loading branch information
mxdvl authored May 30, 2024
1 parent a4eacee commit f2c54a6
Showing 1 changed file with 24 additions and 27 deletions.
51 changes: 24 additions & 27 deletions tools/task-runner/run-task-verbose-formater.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,34 @@ const log = (title, parents, message = '') => {
const render = (tasks, parents = []) => {
// eslint-disable-next-line no-restricted-syntax
for (const task of tasks) {
task.subscribe(event => {
if (event.type === 'SUBTASKS') {
render(task.subtasks, parents.concat([task.title]));
return;
task.on('SUBTASKS', event => {
render(task.subtasks, parents.concat([task.title]));
});
task.on('STATE', event => {
if (task.isPending()) {
log(task.title, parents, chalk.dim('...'));
}
if (task.hasFailed()) {
log(task.title, parents, chalk.red(figures.cross));
}
if (event.type === 'STATE') {
if (task.isPending()) {
log(task.title, parents, chalk.dim('...'));
}
if (task.hasFailed()) {
log(task.title, parents, chalk.red(figures.cross));
}
if (task.isSkipped()) {
log(
task.title,
parents,
`${chalk.dim(figures.arrowDown)} (${task.output})`
);
}
if (
task.isCompleted() &&
!task.hasFailed() &&
!task.isSkipped()
) {
log(task.title, parents, chalk.dim.green(figures.tick));
}
if (task.isSkipped()) {
log(
task.title,
parents,
`${chalk.dim(figures.arrowDown)} (${task.output})`
);
}
if (event.type === 'DATA') {
console.log(event.data);
if (
task.isCompleted() &&
!task.hasFailed() &&
!task.isSkipped()
) {
log(task.title, parents, chalk.dim.green(figures.tick));
}
});
task.on('DATA', event => {
console.log(event.data);
});
}
};

Expand Down

0 comments on commit f2c54a6

Please sign in to comment.