(fileName: string, targetPath: string, mode?: number)
| 55 | * callers fall back to reading the legacy file rather than crashing. |
| 56 | */ |
| 57 | export function migrateLegacyFileSync(fileName: string, targetPath: string, mode?: number): void { |
| 58 | const legacyPath = getLegacyFilePath(fileName); |
| 59 | if (legacyPath === targetPath || fs.existsSync(targetPath) || !fs.existsSync(legacyPath)) { |
| 60 | return; |
| 61 | } |
| 62 | |
| 63 | try { |
| 64 | fs.mkdirSync(path.dirname(targetPath), { recursive: true, mode: 0o700 }); |
| 65 | fs.renameSync(legacyPath, targetPath); |
| 66 | if (mode !== undefined) { |
| 67 | fs.chmodSync(targetPath, mode); |
| 68 | } |
| 69 | } catch { |
| 70 | // Leave the legacy file in place; readers resolve to it via resolveReadPathSync. |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | export async function migrateLegacyFile( |
| 75 | fileName: string, |
no test coverage detected