@@ -2,7 +2,7 @@ import { spawnSync } from 'child_process'
22import { readdirSync } from 'fs'
33import * as path from 'path'
44
5- import { bold , red } from './_common'
5+ import { bold , brightItalic , red } from './_common'
66
77const VERBOSE = process . env . VERBOSE === 'true'
88
@@ -11,10 +11,28 @@ const examplesDir = path.resolve(__dirname, '../examples')
1111const failures : string [ ] = [ ]
1212
1313for ( 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-
5058function formatOutput ( output : string [ ] ) {
5159 return output . filter ( Boolean ) . join ( '\n' )
5260}
0 commit comments