All files / infrastructure/scripts/src/worktree/adapters files.ts

0% Statements 0/12
0% Branches 0/4
0% Functions 0/4
0% Lines 0/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18                                   
import { copyFileSync, existsSync, mkdirSync, realpathSync } from "node:fs";
import { dirname, join } from "node:path";
 
/** Never overwrites, so an env file edited inside the worktree survives a second run. */
export const copyMissing = (from: string, to: string, files: string[]): string[] =>
    files.filter((file) => {
        const target = join(to, file);
        if (existsSync(target)) return false;
 
        mkdirSync(dirname(target), { recursive: true });
        copyFileSync(join(from, file), target);
        return true;
    });
 
export const isInstalled = (root: string): boolean => existsSync(join(root, "node_modules"));
 
export const canonical = (path: string): string => (existsSync(path) ? realpathSync(path) : path);