MCPcopy Create free account
hub / github.com/nodejs/corepack / renameUnderWindows

Function renameUnderWindows

sources/corepackUtils.ts:365–384  ·  view source on GitHub ↗
(oldPath: fs.PathLike, newPath: fs.PathLike)

Source from the content-addressed store, hash-verified

363}
364
365async function renameUnderWindows(oldPath: fs.PathLike, newPath: fs.PathLike) {
366 // Windows malicious file analysis blocks files currently under analysis, so we need to wait for file release
367 const retries = 5;
368 for (let i = 0; i < retries; i++) {
369 try {
370 await fs.promises.rename(oldPath, newPath);
371 break;
372 } catch (err) {
373 if (
374 nodeUtils.isNodeError(err) && (err.code === `ENOENT` || err.code === `EPERM`) &&
375 i < (retries - 1)
376 ) {
377 await setTimeoutPromise(100 * 2 ** i);
378 continue;
379 } else {
380 throw err;
381 }
382 }
383 }
384}
385
386/**
387 * Loads the binary, taking control of the current process.

Callers 1

renameSafeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…