fix(fs/compiler/unpack): robustify directory removal and remove noisy diagnostic logging
This commit is contained in:
@@ -365,48 +365,13 @@ export class TsCompiler {
|
||||
emittedFiles.push(...result.emittedFiles);
|
||||
errorSummaries.push(result.errorSummary);
|
||||
|
||||
// DIAGNOSTIC: Log directory contents after compilation
|
||||
if (!isQuiet && !isJson) {
|
||||
try {
|
||||
const fs = await import('fs');
|
||||
const dirEntries = fs.readdirSync(destDir, { withFileTypes: true });
|
||||
const dirs = dirEntries.filter((e: any) => e.isDirectory()).map((e: any) => e.name).sort();
|
||||
const fileCount = dirEntries.filter((e: any) => e.isFile()).length;
|
||||
console.log(` 📋 [DIAG] After emit: ${dirs.length} dirs [${dirs.join(', ')}], ${fileCount} top-level files`);
|
||||
console.log(` 📋 [DIAG] emittedFiles.length=${result.emittedFiles.length}, totalErrors=${result.errorSummary.totalErrors}`);
|
||||
} catch (e: any) { console.log(` 📋 [DIAG] Error reading destDir: ${e.message}`); }
|
||||
}
|
||||
|
||||
// Perform unpack if compilation succeeded
|
||||
if (result.errorSummary.totalErrors === 0) {
|
||||
await performUnpack(pattern, destDir, this.cwd);
|
||||
|
||||
// DIAGNOSTIC: Log directory contents after unpack
|
||||
if (!isQuiet && !isJson) {
|
||||
try {
|
||||
const fs = await import('fs');
|
||||
const dirEntries = fs.readdirSync(destDir, { withFileTypes: true });
|
||||
const dirs = dirEntries.filter((e: any) => e.isDirectory()).map((e: any) => e.name).sort();
|
||||
const fileCount = dirEntries.filter((e: any) => e.isFile()).length;
|
||||
console.log(` 📋 [DIAG] After unpack: ${dirs.length} dirs [${dirs.join(', ')}], ${fileCount} top-level files`);
|
||||
} catch (e: any) { console.log(` 📋 [DIAG] Error reading destDir after unpack: ${e.message}`); }
|
||||
}
|
||||
|
||||
successfulOutputDirs.push(destDir);
|
||||
}
|
||||
|
||||
// DIAGNOSTIC: Check dist_ts after each task (not just current destDir)
|
||||
if (!isQuiet && !isJson) {
|
||||
try {
|
||||
const fs = await import('fs');
|
||||
const distTsPath = require('path').join(this.cwd, 'dist_ts');
|
||||
if (fs.existsSync(distTsPath)) {
|
||||
const dirEntries = fs.readdirSync(distTsPath, { withFileTypes: true });
|
||||
const dirs = dirEntries.filter((e: any) => e.isDirectory()).map((e: any) => e.name).sort();
|
||||
console.log(` 📋 [DIAG-CROSSTASK] dist_ts after task ${currentTask}: ${dirs.length} dirs [${dirs.join(', ')}]`);
|
||||
}
|
||||
} catch (e: any) { /* ignore */ }
|
||||
}
|
||||
}
|
||||
|
||||
// Rewrite import paths in all output directories to handle cross-module references
|
||||
@@ -423,20 +388,6 @@ export class TsCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
// DIAGNOSTIC: Check dist_ts after path rewriting
|
||||
if (!isQuiet && !isJson) {
|
||||
for (const outputDir of successfulOutputDirs) {
|
||||
try {
|
||||
const fs = await import('fs');
|
||||
const dirEntries = fs.readdirSync(outputDir, { withFileTypes: true });
|
||||
const dirs = dirEntries.filter((e: any) => e.isDirectory()).map((e: any) => e.name).sort();
|
||||
const fileCount = dirEntries.filter((e: any) => e.isFile()).length;
|
||||
const relDir = outputDir.replace(this.cwd, '').replace(/^\//, '');
|
||||
console.log(` 📋 [DIAG-FINAL] ${relDir}: ${dirs.length} dirs [${dirs.join(', ')}], ${fileCount} files`);
|
||||
} catch (e: any) { console.log(` 📋 [DIAG-FINAL] Error: ${e.message}`); }
|
||||
}
|
||||
}
|
||||
|
||||
// Merge all error summaries
|
||||
const finalErrorSummary = this.mergeErrorSummaries(errorSummaries);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user