-
-
Notifications
You must be signed in to change notification settings - Fork 58
/
_selftest.ts
30 lines (29 loc) · 905 Bytes
/
_selftest.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import path from 'path'
import fs from 'fs'
import { runInRepo } from '../utils.ts'
import type { RunOptions } from '../types.d.ts'
export async function test(options: RunOptions) {
await runInRepo({
...options,
repo: 'vitejs/vite-ecosystem-ci',
build: async () => {
const dir = path.resolve(options.workspace, 'vite-ecosystem-ci')
const pkgFile = path.join(dir, 'package.json')
const pkg = JSON.parse(await fs.promises.readFile(pkgFile, 'utf-8'))
if (pkg.name !== 'vite-ecosystem-ci') {
throw new Error(
`invalid checkout, expected package.json with "name":"vite-ecosystem-ci" in ${dir}`,
)
}
pkg.scripts.selftestscript =
"[ -d ../../vite/packages/vite/dist ] || (echo 'vite build failed' && exit 1)"
await fs.promises.writeFile(
pkgFile,
JSON.stringify(pkg, null, 2),
'utf-8',
)
},
test: 'pnpm run selftestscript',
verify: false,
})
}