20 lines
649 B
TypeScript
20 lines
649 B
TypeScript
|
|
import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||
|
|
import { resolve } from 'node:path';
|
||
|
|
|
||
|
|
import type { SeedArtifact } from './types.js';
|
||
|
|
|
||
|
|
export const ARTIFACT_PATH = resolve(process.cwd(), '.e2e-prod.local.json');
|
||
|
|
|
||
|
|
export function writeArtifact(artifact: SeedArtifact): void {
|
||
|
|
writeFileSync(ARTIFACT_PATH, JSON.stringify(artifact, null, 2));
|
||
|
|
}
|
||
|
|
|
||
|
|
export function readArtifact(): SeedArtifact | null {
|
||
|
|
if (!existsSync(ARTIFACT_PATH)) return null;
|
||
|
|
return JSON.parse(readFileSync(ARTIFACT_PATH, 'utf8')) as SeedArtifact;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function removeArtifact(): void {
|
||
|
|
if (existsSync(ARTIFACT_PATH)) rmSync(ARTIFACT_PATH);
|
||
|
|
}
|