diff --git a/index.js b/index.js
index ce5a65639d49b3fc665b35d4b0d162e092c9d612..445bbadf62a85b4aab4728c3aafa34fd30c3caf9 100644
--- a/index.js
+++ b/index.js
@@ -29,7 +29,7 @@ const checkCwdOption = options => {
let stat;
try {
- stat = fs.statSync(options.cwd);
+ stat = (options?.fs ?? fs).statSync(options.cwd);
} catch {
return;
}
otherwise, it may yield a false positive.
let's say a user is mocking the file system with memfs. if options.cwd resolves to a directory on their machine, but isn't found in their mock file system, checkCwdOption will not catch the error. it checks the wrong file system.
fast-glob
allows the use of custom file system functions via thefs
option.checkCwdOption
should respectoptions.fs
:otherwise, it may yield a false positive.
let's say a user is mocking the file system with
memfs
. ifoptions.cwd
resolves to a directory on their machine, but isn't found in their mock file system,checkCwdOption
will not catch the error. it checks the wrong file system.