Skip to content

Commit 2b4286d

Browse files
committed
Fix examples tests
1 parent 918833b commit 2b4286d

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ jobs:
6767
- uses: pnpm/action-setup@v2.4.0
6868
with:
6969
version: 8.x.x
70-
run_install: true
7170

7271
- name: Test
7372
run: node scripts/build-examples.mjs

scripts/build-examples.mjs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
1-
import { readdirSync, readFileSync, existsSync } from 'fs'
2-
import { execa } from 'execa'
1+
import { existsSync, readFileSync, readdirSync } from 'node:fs'
2+
import { spawn } from 'node:child_process'
3+
4+
function exec(command, params, ops) {
5+
const p = spawn(command, params, ops)
6+
7+
return new Promise((resolve) => {
8+
p.on('exit', (code) => {
9+
resolve(code)
10+
})
11+
})
12+
}
313

414
const examples = readdirSync('examples')
5-
.filter((f) => existsSync(`examples/${f}/package.json`))
6-
.map((f) => ({
15+
.filter(f => existsSync(`examples/${f}/package.json`))
16+
.map(f => ({
717
folder: `examples/${f}`,
818
package: JSON.parse(readFileSync(`examples/${f}/package.json`)),
919
}))
1020

11-
async function buildExamples () {
12-
await execa('pnpm', ['i'], { stdio: 'inherit' })
13-
await execa('pnpm', ['build'], { stdio: 'inherit' })
21+
async function buildExamples() {
22+
await exec('pnpm', ['i'], { stdio: 'inherit' })
23+
await exec('pnpm', ['build'], { stdio: 'inherit' })
24+
await exec('pnpm', ['rimraf', 'node_modules'], { stdio: 'inherit' })
1425

1526
for (const example of examples) {
1627
console.log(`building ${example.folder}...`)
17-
await execa('pnpm', ['add', `link:../../`], { stdio: 'inherit', cwd: example.folder })
18-
await execa('pnpm', ['i'], { stdio: 'inherit', cwd: example.folder })
19-
await execa('pnpm', ['build'], { stdio: 'inherit', cwd: example.folder })
28+
await exec('pnpm', ['add', 'file:../../'], { stdio: 'inherit', cwd: example.folder })
29+
await exec('pnpm', ['i'], { stdio: 'inherit', cwd: example.folder })
30+
await exec('pnpm', ['build'], { stdio: 'inherit', cwd: example.folder })
2031
}
2132

22-
for (const typescriptExample of examples.filter((ex) => ex.package.scripts.typecheck != null)) {
33+
for (const typescriptExample of examples.filter(ex => ex.package.scripts.typecheck != null)) {
2334
console.log(`typechecking ${typescriptExample.folder}...`)
24-
await execa('pnpm', ['typecheck'], { stdio: 'inherit', cwd: typescriptExample.folder })
35+
await exec('pnpm', ['typecheck'], { stdio: 'inherit', cwd: typescriptExample.folder })
2536
}
2637
}
2738

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy