@@ -50,17 +50,21 @@ export function* visitFiles(root: string, test?: (name: string) => boolean): Gen
50
50
const visited = new Set < number > ( ) ;
51
51
const queue : string [ ] = [ ( root = normalize ( root ) ) ] ;
52
52
for ( const path of queue ) {
53
- const status = statSync ( path ) ;
54
- if ( status . isDirectory ( ) ) {
55
- if ( visited . has ( status . ino ) ) continue ; // circular symlink
56
- visited . add ( status . ino ) ;
57
- for ( const entry of readdirSync ( path ) ) {
58
- if ( entry === ".observablehq" ) continue ; // ignore the .observablehq directory
59
- if ( test !== undefined && ! test ( entry ) ) continue ;
60
- queue . push ( join ( path , entry ) ) ;
53
+ try {
54
+ const status = statSync ( path ) ;
55
+ if ( status . isDirectory ( ) ) {
56
+ if ( visited . has ( status . ino ) ) continue ; // circular symlink
57
+ visited . add ( status . ino ) ;
58
+ for ( const entry of readdirSync ( path ) ) {
59
+ if ( entry === ".observablehq" ) continue ; // ignore the .observablehq directory
60
+ if ( test !== undefined && ! test ( entry ) ) continue ;
61
+ queue . push ( join ( path , entry ) ) ;
62
+ }
63
+ } else {
64
+ yield relative ( root , path ) ;
61
65
}
62
- } else {
63
- yield relative ( root , path ) ;
66
+ } catch ( error ) {
67
+ if ( ! isEnoent ( error ) ) throw error ;
64
68
}
65
69
}
66
70
}
0 commit comments