import { exec } from 'child_process'; import chalk from 'chalk'; import ora from 'ora'; async function runCommand(command: string, description: string): Promise { const spinner = ora(`Running ${description}...`).start(); return new Promise((resolve, reject) => { exec(command, (error, stdout, stderr) => { if (error) { spinner.fail(`${description} failed.`); console.error(chalk.red(`${description} failed.`)); console.error(chalk.red(stderr)); reject(new Error(stderr)); } else { spinner.succeed(`${description} passed.`); console.log(chalk.green(`${description} passed.`)); console.log(stdout); resolve(); } }); }); } async function runLint(): Promise { try { await runCommand('npm run lint:prettier', 'Prettier check'); console.log(chalk.green('All checks passed.')); process.exit(0); } catch (err) { console.error(chalk.red('Lint checks failed.')); console.error(chalk.red('Please fix the issues above and try again.')); console.error( chalk.yellow( `Hint: You can run ${chalk.cyan('npm run prettier')} to automatically format your code.` ) ); process.exit(1); } } runLint();