@@ -56,7 +56,7 @@ function cpSyncFn(src, dest, opts) {
5656 // Skip C++ path checks for VFS paths (C++ lstat can't see VFS files).
5757 // The JS-level getStats() calls lstatSync which is VFS-intercepted.
5858 const { vfsState } = require ( 'internal/fs/utils' ) ;
59- if ( vfsState . handlers === null || ! vfsState . handlers . statSync ( src ) ) {
59+ if ( ! vfsState . handlers ? .statSync ( src ) ) {
6060 fsBinding . cpSyncCheckPaths ( src , dest , opts . dereference , opts . recursive ) ;
6161 } else {
6262 // Minimal JS-level validation that mirrors what C++ does
@@ -103,7 +103,7 @@ function onFile(srcStat, destStat, src, dest, opts) {
103103 if ( opts . force ) {
104104 // Skip C++ fast path for VFS paths (C++ can't see VFS files).
105105 const { vfsState } = require ( 'internal/fs/utils' ) ;
106- if ( vfsState . handlers === null || ! vfsState . handlers . statSync ( src ) ) {
106+ if ( ! vfsState . handlers ? .statSync ( src ) ) {
107107 return fsBinding . cpSyncOverrideFile ( src , dest , opts . mode , opts . preserveTimestamps ) ;
108108 }
109109 unlinkSync ( dest ) ;
@@ -167,7 +167,7 @@ function copyDir(src, dest, opts, mkDir, srcMode) {
167167 // we can run the whole function faster in C++.
168168 // Skip C++ fast path for VFS paths (C++ can't see VFS files).
169169 const { vfsState } = require ( 'internal/fs/utils' ) ;
170- if ( vfsState . handlers === null || ! vfsState . handlers . statSync ( src ) ) {
170+ if ( ! vfsState . handlers ? .statSync ( src ) ) {
171171 // TODO(dario-piotrowicz): look into making cpSyncCopyDir also accept the potential filter function
172172 return fsBinding . cpSyncCopyDir ( src , dest ,
173173 opts . force ,
@@ -240,8 +240,9 @@ function onLink(destStat, src, dest, verbatimSymlinks) {
240240 // internalModuleStat is a C++ call that can't see VFS files.
241241 const { vfsState } = require ( 'internal/fs/utils' ) ;
242242 let srcIsDir ;
243- if ( vfsState . handlers !== null && vfsState . handlers . statSync ( src ) ) {
244- srcIsDir = statSync ( src ) . isDirectory ( ) ;
243+ const vfsStat = vfsState . handlers ?. statSync ( src ) ;
244+ if ( vfsStat ) {
245+ srcIsDir = vfsStat . isDirectory ( ) ;
245246 } else {
246247 srcIsDir = fsBinding . internalModuleStat ( src ) === 1 ;
247248 }
0 commit comments