MCPcopy Index your code
hub / github.com/Waishnav/devspace / replaceFile

Function replaceFile

src/apply-patch.ts:295–315  ·  view source on GitHub ↗
(
  temporary: string,
  destination: string,
  destinationExists: boolean,
  platform: NodeJS.Platform = process.platform,
)

Source from the content-addressed store, hash-verified

293}
294
295export 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
317export async function applyPatch(root: string, patch: string): Promise<ApplyPatchResult> {
318 const actions = parsePatch(patch);

Callers 2

writeTextFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected