2024-01-17 11:46:13 +00:00
|
|
|
import { fileURLToPath } from 'node:url'
|
2024-06-24 13:33:47 +00:00
|
|
|
import { readdir, rm } from 'node:fs/promises'
|
2024-06-24 09:39:38 +00:00
|
|
|
|
2024-01-17 11:46:13 +00:00
|
|
|
import { execa } from 'execa'
|
2024-06-24 13:33:47 +00:00
|
|
|
import { join } from 'pathe'
|
2024-01-17 11:46:13 +00:00
|
|
|
|
|
|
|
async function initTesting () {
|
2024-06-24 13:33:47 +00:00
|
|
|
const fixturesDir = fileURLToPath(new URL('./fixtures', import.meta.url))
|
|
|
|
const dirs = await readdir(fixturesDir)
|
2024-01-17 11:46:13 +00:00
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
// clear nuxt build files
|
2024-06-24 13:33:47 +00:00
|
|
|
...dirs.map(dir => rm(join(fixturesDir, `${dir}/.nuxt`), { force: true, recursive: true })),
|
2024-01-17 11:46:13 +00:00
|
|
|
// clear vite cache
|
2024-06-24 13:33:47 +00:00
|
|
|
...dirs.map(dir => rm(join(fixturesDir, `${dir}/node_modules/.cache`), { force: true, recursive: true })),
|
2024-01-17 11:46:13 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
await Promise.all(
|
2024-06-24 13:33:47 +00:00
|
|
|
dirs.map(dir => execa('pnpm', ['nuxi', 'prepare'], { cwd: join(fixturesDir, dir) })),
|
2024-01-17 11:46:13 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
initTesting()
|