-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-examples.mjs
28 lines (23 loc) · 1.04 KB
/
build-examples.mjs
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
import { readdirSync, readFileSync, existsSync } from 'fs'
import { execa } from 'execa'
const examples = readdirSync('examples')
.filter((f) => existsSync(`examples/${f}/package.json`))
.map((f) => ({
folder: `examples/${f}`,
package: JSON.parse(readFileSync(`examples/${f}/package.json`)),
}))
async function buildExamples () {
await execa('pnpm', ['i'], { stdio: 'inherit' })
await execa('pnpm', ['build'], { stdio: 'inherit' })
for (const example of examples) {
console.log(`building ${example.folder}...`)
await execa('pnpm', ['add', `file:../../`], { stdio: 'inherit', cwd: example.folder })
await execa('pnpm', ['i'], { stdio: 'inherit', cwd: example.folder })
await execa('pnpm', ['build'], { stdio: 'inherit', cwd: example.folder })
}
for (const typescriptExample of examples.filter((ex) => ex.package.scripts.typecheck != null)) {
console.log(`typechecking ${typescriptExample.folder}...`)
await execa('pnpm', ['typecheck'], { stdio: 'inherit', cwd: typescriptExample.folder })
}
}
await buildExamples()