Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
import { mkdtemp, cp, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { execa } from 'execa';
export const FIXTURE = path.join(path.dirname(fileURLToPath(import.meta.url)), 'fixtures', 'open-key');
export const REPORTS = path.join(path.dirname(fileURLToPath(import.meta.url)), 'fixtures', 'reports');
/** Copy the open-key fixture into a fresh temp dir and git-init it. */
export async function tempFixtureRepo(): Promise<{ repo: string; cleanup: () => Promise<void> }> {
const repo = await mkdtemp(path.join(tmpdir(), 'copperhead-test-'));
await cp(FIXTURE, repo, { recursive: true });
// the target-repo convention (AC-4.3): .env and the run audit trail ignored
await writeFile(path.join(repo, '.gitignore'), '.env\n.copperhead/runs/\n', 'utf8');
await execa('git', ['init', '-q'], { cwd: repo });
await execa('git', ['config', 'user.email', 'test@copperhead.local'], { cwd: repo });
await execa('git', ['config', 'user.name', 'copperhead-test'], { cwd: repo });
await execa('git', ['add', '-A'], { cwd: repo });
await execa('git', ['commit', '-q', '-m', 'fixture'], { cwd: repo });
return { repo, cleanup: () => rm(repo, { recursive: true, force: true }) };
}
54e85dd7fThis file is pinned to the selected release. Download the original to open it in your design tool.