From d3211173608490879b62ab0fe6bd1cf3d4ab5f33 Mon Sep 17 00:00:00 2001 From: StrangeDrVN <172238701+StrangeDrVN@users.noreply.github.com> Date: Wed, 15 Jul 2026 10:43:52 +0530 Subject: [PATCH] add confirmation to remove broken links to prevent testing the links again --- scripts/commands/playlist/test.ts | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/scripts/commands/playlist/test.ts b/scripts/commands/playlist/test.ts index 0f5629ec6a..24d1b01fe6 100644 --- a/scripts/commands/playlist/test.ts +++ b/scripts/commands/playlist/test.ts @@ -8,6 +8,7 @@ import { Playlist, Stream } from '../../models' import { truncate } from '../../utils' import { loadData } from '../../api' import { eachLimit } from 'async' +import { confirm } from '@inquirer/prompts' import dns from 'node:dns' import chalk from 'chalk' import os from 'node:os' @@ -172,20 +173,36 @@ async function onFinish(error: Error | null | undefined) { process.exit(1) } - if (options.fix) { - await removeBrokenLinks() - } - drawTable() if (errors > 0 || warnings > 0) { console.log( chalk.red(`\n${errors + warnings} problems (${errors} errors, ${warnings} warnings)`) ) + } - if (errors > 0) { - process.exit(1) + if (options.fix) { + await removeBrokenLinks() + console.log(chalk.green('\nBroken links removed successfully.')) + } else if (errors > 0) { + console.log() + + try { + const shouldFix = await confirm({ + message: `Found ${errors} broken links. Do you want to remove them now?`, + default: false + }) + + if (shouldFix) { + await removeBrokenLinks() + console.log(chalk.green('\nBroken links removed successfully.')) + } else { + console.log(chalk.yellow('\nNo changes made.')) + } + } catch (err) { + console.log(chalk.yellow('\n\nPrompt interrupted by user. No files were modified.')) } + process.exit(0) } process.exit(0)