fix(tsbuild): Avoid process.exit in library, add confirmskiplibcheck flag, improve CLI exit handling and JSON/quiet modes, update test script

This commit is contained in:
2025-08-29 17:14:58 +00:00
parent 55c1a2953a
commit 746ca8767a
6 changed files with 94 additions and 24 deletions

View File

@@ -130,12 +130,16 @@ export let compileGlobStringObject = async (
const totalTasks = Object.keys(globStringObjectArg).length;
let currentTask = 0;
// Log the compilation tasks in a nice format
console.log(`\n👷 TypeScript Compilation Tasks (${totalTasks} task${totalTasks !== 1 ? 's' : ''}):`);
Object.entries(globStringObjectArg).forEach(([source, dest]) => {
console.log(` 📂 ${source}${dest}`);
});
console.log('');
// Log the compilation tasks in a nice format (skip for --quiet or --json)
const isQuiet = argvArg?.quiet === true;
const isJson = argvArg?.json === true;
if (!isQuiet && !isJson) {
console.log(`\n👷 TypeScript Compilation Tasks (${totalTasks} task${totalTasks !== 1 ? 's' : ''}):`);
Object.entries(globStringObjectArg).forEach(([source, dest]) => {
console.log(` 📂 ${source}${dest}`);
});
console.log('');
}
for (const keyArg in globStringObjectArg) {
// Type safety check for key
@@ -185,7 +189,35 @@ export let compileGlobStringObject = async (
// Display final error summary after all compilation tasks
const finalErrorSummary = mergeErrorSummaries(errorSummaries);
displayFinalErrorSummary(finalErrorSummary);
// Output summary based on mode
if (isJson) {
const result = {
success: finalErrorSummary.totalErrors === 0,
totals: {
errors: finalErrorSummary.totalErrors,
filesWithErrors: finalErrorSummary.totalFiles,
tasks: totalTasks,
},
errorsByFile: Object.fromEntries(
Object.entries(finalErrorSummary.errorsByFile).map(([file, diags]) => [
file,
diags.map(d => ({
code: d.code,
message: plugins.typescript.flattenDiagnosticMessageText(d.messageText as any, '\n'),
}))
])
),
};
console.log(JSON.stringify(result));
} else if (!isQuiet) {
displayFinalErrorSummary(finalErrorSummary);
}
// Attach summary to argvArg so CLI can decide exit behavior
if (argvArg && typeof argvArg === 'object') {
(argvArg as any).__tsbuildFinalErrorSummary = finalErrorSummary;
}
return compiledFiles;
};
};