Skip to content

Commit bd15b5c

Browse files
authored
Run typecheck in check-examples.ts (again) (#505)
* Run typecheck in check-examples.ts (again) * Run yarn with --frozen-lockfile
1 parent 4d4df79 commit bd15b5c

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

scripts/check-examples.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { spawnSync } from 'child_process'
22
import { readdirSync } from 'fs'
33
import * as path from 'path'
44

5-
import { bold, red } from './_common'
5+
import { bold, brightItalic, red } from './_common'
66

77
const VERBOSE = process.env.VERBOSE === 'true'
88

@@ -11,10 +11,28 @@ const examplesDir = path.resolve(__dirname, '../examples')
1111
const failures: string[] = []
1212

1313
for (const dir of readdirSync(examplesDir)) {
14-
console.log(`Checking example: ${dir}`)
14+
console.log(`Checking example: ${bold(dir)}`)
1515

1616
const yarn = process.platform === 'win32' ? 'yarn.cmd' : 'yarn'
17-
const childProcess = spawnSync(yarn, ['--non-interactive'], {
17+
runProcess([yarn, '--non-interactive', '--frozen-lockfile'], dir)
18+
runProcess([yarn, 'typecheck'], dir)
19+
}
20+
21+
if (failures.length > 0) {
22+
console.error(
23+
'\n',
24+
bold(failures.length) + ` example${failures.length > 1 ? 's' : ''} failed:`,
25+
red(failures.join(', ')),
26+
'\n',
27+
)
28+
process.exit(1)
29+
}
30+
31+
function runProcess(command: string[], dir: string) {
32+
console.log(brightItalic(command.join(' ')))
33+
34+
const [program, ...args] = command
35+
const childProcess = spawnSync(program, args, {
1836
cwd: path.resolve(examplesDir, dir),
1937
encoding: 'utf-8',
2038
env: {
@@ -37,16 +55,6 @@ for (const dir of readdirSync(examplesDir)) {
3755
}
3856
}
3957

40-
if (failures.length > 0) {
41-
console.error(
42-
'\n',
43-
bold(failures.length) + ` example${failures.length > 1 ? 's' : ''} failed:`,
44-
red(failures.join(', ')),
45-
'\n',
46-
)
47-
process.exit(1)
48-
}
49-
5058
function formatOutput(output: string[]) {
5159
return output.filter(Boolean).join('\n')
5260
}

0 commit comments

Comments
 (0)