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:
@@ -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;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user