feat: fix CLI UI error when trying to display non-existent complexity report

This commit is contained in:
Ralph Khreish
2025-07-24 15:08:35 +03:00
parent 31b8407dbc
commit 292bc3ff49
3 changed files with 567 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ import boxen from 'boxen';
import ora from 'ora';
import Table from 'cli-table3';
import gradient from 'gradient-string';
import readline from 'readline';
import {
log,
findTaskById,
@@ -1682,18 +1683,18 @@ async function displayComplexityReport(reportPath) {
)
);
const readline = require('readline').createInterface({
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const answer = await new Promise((resolve) => {
readline.question(
rl.question(
chalk.cyan('Generate complexity report? (y/n): '),
resolve
);
});
readline.close();
rl.close();
if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
// Call the analyze-complexity command
@@ -1974,8 +1975,6 @@ async function confirmTaskOverwrite(tasksPath) {
)
);
// Use dynamic import to get the readline module
const readline = await import('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
@@ -2463,8 +2462,6 @@ async function displayMultipleTasksSummary(
)
);
// Use dynamic import for readline
const readline = await import('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout