Nuxt/test/setup.ts

26 lines
653 B
TypeScript
Raw Permalink Normal View History

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-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 () {
if (existsSync(tempDir)) {
await rm(tempDir, { force: true, recursive: true })
2023-01-22 16:46:45 +00:00
}
await cp(fixtureDir, tempDir, {
recursive: true,
filter: src => !src.includes('.cache'),
})
2023-01-22 16:46:45 +00:00
}
export async function teardown () {
if (existsSync(tempDir)) {
await rm(tempDir, { force: true, recursive: true })
2023-01-22 16:46:45 +00:00
}
}