test: remove the asset test temp folders after the run
This commit is contained in:
@@ -6,7 +6,7 @@ import { execFile } from 'node:child_process';
|
||||
import { promisify } from 'node:util';
|
||||
import sharp from 'sharp';
|
||||
import { BarcodeFormat, MultiFormatWriter } from '@zxing/library';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { afterAll, describe, expect, it } from 'vitest';
|
||||
|
||||
// @ts-expect-error The production script is native ESM and intentionally has no TypeScript runtime wrapper.
|
||||
import { hashFile } from '../../scripts/lib/hash-file.mjs';
|
||||
@@ -22,7 +22,16 @@ import { generateSocialPreview } from '../../scripts/generate-social-preview.mjs
|
||||
const execFileAsync = promisify(execFile);
|
||||
interface Candidate { id: string; fileName: string; sha256: string; }
|
||||
|
||||
const createRoot = async (): Promise<string> => mkdtemp(join(tmpdir(), 'portfolio-assets-test-'));
|
||||
const roots: string[] = [];
|
||||
const createRoot = async (): Promise<string> => {
|
||||
const root = await mkdtemp(join(tmpdir(), 'portfolio-assets-test-'));
|
||||
roots.push(root);
|
||||
return root;
|
||||
};
|
||||
|
||||
afterAll(async () => {
|
||||
await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true })));
|
||||
});
|
||||
|
||||
const writeJson = async (path: string, value: unknown): Promise<void> => {
|
||||
await writeFile(path, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
|
||||
|
||||
Reference in New Issue
Block a user