fix(format): Improve concurrency control in cache and rollback modules, refine gitignore custom section handling, and enhance Prettier file processing

This commit is contained in:
2025-08-08 06:50:58 +00:00
parent 74a8229e43
commit 74ecdde1ac
12 changed files with 265 additions and 68 deletions

View File

@@ -53,7 +53,19 @@ export abstract class BaseFormatter {
}
protected async modifyFile(filepath: string, content: string): Promise<void> {
await plugins.smartfile.memory.toFs(content, filepath);
// Validate filepath before writing
if (!filepath || filepath.trim() === '') {
throw new Error(`Invalid empty filepath in modifyFile`);
}
// Ensure we have a proper path with directory component
// If the path has no directory component (e.g., "package.json"), prepend "./"
let normalizedPath = filepath;
if (!plugins.path.parse(filepath).dir) {
normalizedPath = './' + filepath;
}
await plugins.smartfile.memory.toFs(content, normalizedPath);
}
protected async createFile(filepath: string, content: string): Promise<void> {