@@ -14,44 +14,44 @@ const srcDir = join(import.meta.dir, 'src');
1414function findExamples ( dir : string ) : string [ ] {
1515 const entries = readdirSync ( dir ) ;
1616 const files : string [ ] = [ ] ;
17-
17+
1818 for ( const entry of entries ) {
1919 const fullPath = join ( dir , entry ) ;
2020 const stat = statSync ( fullPath ) ;
21-
21+
2222 if ( stat . isDirectory ( ) ) {
2323 files . push ( ...findExamples ( fullPath ) ) ;
2424 } else if ( entry . endsWith ( '.ts' ) ) {
2525 files . push ( fullPath ) ;
2626 }
2727 }
28-
28+
2929 return files . sort ( ) ;
3030}
3131
3232const examples = findExamples ( srcDir ) ;
3333console . log ( `Found ${ examples . length } example(s)\n` ) ;
3434
35- let failed = 0 ;
35+ const failedCountRef = { current : 0 } ;
3636for ( const example of examples ) {
3737 const relativePath = example . replace ( import . meta. dir + '/' , '' ) ;
3838 console . log ( `\n${ '=' . repeat ( 80 ) } ` ) ;
3939 console . log ( `Running: ${ relativePath } ` ) ;
4040 console . log ( '=' . repeat ( 80 ) ) ;
41-
41+
4242 try {
4343 await $ `bun run ${ example } ` . quiet ( ) ;
4444 console . log ( `✅ ${ relativePath } completed successfully` ) ;
4545 } catch ( error ) {
4646 console . error ( `❌ ${ relativePath } failed` ) ;
47- failed ++ ;
47+ failedCountRef . current ++ ;
4848 }
4949}
5050
5151console . log ( `\n${ '=' . repeat ( 80 ) } ` ) ;
52- console . log ( `Results: ${ examples . length - failed } /${ examples . length } passed` ) ;
52+ console . log ( `Results: ${ examples . length - failedCountRef . current } /${ examples . length } passed` ) ;
5353console . log ( '=' . repeat ( 80 ) ) ;
5454
55- if ( failed > 0 ) {
55+ if ( failedCountRef . current > 0 ) {
5656 process . exit ( 1 ) ;
5757}
0 commit comments