MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / moveLockedExeAside

Function moveLockedExeAside

src/upgrade/remove-binary.ts:249–261  ·  view source on GitHub ↗

* Rename the running (locked) node.exe out of `dir` so the rest of the tree * deletes cleanly — Windows allows renaming a mapped image, just not deleting * it. Returns the leftover path, or null when nothing needed moving.

(dir: string, deps: RemoveBinaryDeps)

Source from the content-addressed store, hash-verified

247 * it. Returns the leftover path, or null when nothing needed moving.
248 */
249function moveLockedExeAside(dir: string, deps: RemoveBinaryDeps): string | null {
250 if (deps.platform !== 'win32') return null;
251 const P = pathFor(deps.platform);
252 const resolvedDir = P.resolve(dir) + P.sep;
253 if (!P.resolve(deps.execPath).startsWith(resolvedDir)) return null;
254 const leftover = P.join(P.dirname(P.resolve(dir)), `codegraph-old-node-${process.pid}.exe`);
255 try {
256 deps.rename(deps.execPath, leftover);
257 return leftover;
258 } catch {
259 return null; // rename failed too — the rm error will surface the dir
260 }
261}
262
263export function executeBinaryRemoval(
264 plan: BinaryRemovalPlan,

Callers 1

executeBinaryRemovalFunction · 0.85

Calls 3

pathForFunction · 0.85
resolveMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected