2024-06-24 09:39:38 +00:00
|
|
|
import { existsSync } from 'node:fs'
|
|
|
|
import { cp, rm } from 'node:fs/promises'
|
2023-01-22 16:46:45 +00:00
|
|
|
import { fileURLToPath } from 'node:url'
|
2024-06-24 09:39:38 +00:00
|
|
|
|
2024-02-05 11:24:39 +00:00
|
|
|
import { dirname, join } from 'pathe'
|
2023-01-22 16:46:45 +00:00
|
|
|
|
|
|
|
const dir = dirname(fileURLToPath(import.meta.url))
|
|
|
|
const fixtureDir = join(dir, 'fixtures')
|
|
|
|
const tempDir = join(dir, 'fixtures-temp')
|
|
|
|
|
|
|
|
export async function setup () {
|
2024-06-24 09:39:38 +00:00
|
|
|
if (existsSync(tempDir)) {
|
|
|
|
await rm(tempDir, { force: true, recursive: true })
|
2023-01-22 16:46:45 +00:00
|
|
|
}
|
2024-06-24 09:39:38 +00:00
|
|
|
await cp(fixtureDir, tempDir, {
|
|
|
|
recursive: true,
|
2024-04-05 18:08:32 +00:00
|
|
|
filter: src => !src.includes('.cache'),
|
2023-07-19 14:43:28 +00:00
|
|
|
})
|
2023-01-22 16:46:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function teardown () {
|
2024-06-24 09:39:38 +00:00
|
|
|
if (existsSync(tempDir)) {
|
|
|
|
await rm(tempDir, { force: true, recursive: true })
|
2023-01-22 16:46:45 +00:00
|
|
|
}
|
|
|
|
}
|