( temporary: string, destination: string, destinationExists: boolean, platform: NodeJS.Platform = process.platform, )
| 293 | } |
| 294 | |
| 295 | export async function replaceFile( |
| 296 | temporary: string, |
| 297 | destination: string, |
| 298 | destinationExists: boolean, |
| 299 | platform: NodeJS.Platform = process.platform, |
| 300 | ): Promise<void> { |
| 301 | if (platform !== "win32" || !destinationExists) { |
| 302 | await rename(temporary, destination); |
| 303 | return; |
| 304 | } |
| 305 | |
| 306 | const backup = `${temporary}.original`; |
| 307 | await rename(destination, backup); |
| 308 | try { |
| 309 | await rename(temporary, destination); |
| 310 | } catch (error) { |
| 311 | await rename(backup, destination); |
| 312 | throw error; |
| 313 | } |
| 314 | await rm(backup, { force: true }); |
| 315 | } |
| 316 | |
| 317 | export async function applyPatch(root: string, patch: string): Promise<ApplyPatchResult> { |
| 318 | const actions = parsePatch(patch); |
no outgoing calls
no test coverage detected