mirror of
https://github.com/Matysh/houseplan-card
synced 2026-09-29 03:09:36 +00:00
test: detach Windows mutation worktree dependencies safely
Issue: #282 User-Visible: no
This commit is contained in:
@@ -30,7 +30,8 @@
|
||||
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import {
|
||||
cpSync, existsSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync,
|
||||
cpSync, existsSync, mkdtempSync, readFileSync, rmSync, symlinkSync, unlinkSync,
|
||||
writeFileSync,
|
||||
} from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
@@ -3016,6 +3017,11 @@ function makeWorktree() {
|
||||
}
|
||||
|
||||
function dropWorktree(dir) {
|
||||
// On Windows a directory junction can be traversed by recursive worktree
|
||||
// cleanup. Detach it first; otherwise removing the mutant may empty the real
|
||||
// repository's node_modules target instead of deleting only the junction.
|
||||
const modules = join(dir, 'node_modules');
|
||||
if (existsSync(modules)) unlinkSync(modules);
|
||||
spawnSync('git', ['-C', repoRoot, 'worktree', 'remove', '--force', dir], { encoding: 'utf8' });
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user