tschaub / mock-fs

Configurable mock for the fs module
https://npmjs.org/package/mock-fs
Other
911 stars 86 forks source link

access failing under 5.5.0 #79

Closed cxreg closed 8 years ago

cxreg commented 8 years ago

I feel like I must be doing something wrong, but I can't figure out what is happening here

I've golfed it down to this:

$ node -e 'require("mock-fs")({}); require("fs").access("foo",function(){});' node_modules/mock-fs/node/fs-5.0.0.js:196 binding.access(pathModule._makeLong(path), mode, req); ^

TypeError: binding.access is not a function at Object.fs.access (/home/dolszewski/mx/voice/dropcamel/node_modules/mock-fs/node/fs-5.0.0.js:196:11) at [eval]:1:39 at Object.exports.runInThisContext (vm.js:54:17) at Object. ([eval]-wrapper:6:22) at Module._compile (module.js:413:34) at node.js:611:27 at nextTickCallbackWith0Args (node.js:452:9) at process._tickCallback (node.js:381:13)

any ideas?

cxreg commented 8 years ago

This seems to be stemming from the fact that lib/binding.js simply does not have Binding.prototype.access at all. I'm not sure how this ever worked. Maybe it didn't?

I ran into this porting my calls of fs.exists to fs.access, which could explain why it's a new issue for me.

I hacked together a quick proof of concept using Binding.prototype.stat and it worked, so this does seem to be the problem.

tschaub commented 8 years ago

What version of Node are you running?

It looks like this would be fixed with #78 - though I'd like to see tests for the fs functions where this is needed.

tschaub commented 8 years ago

What version of Node are you running?

I see 5.5.5 in the title.

tschaub commented 8 years ago

@cxreg mock-fs@3.7.0 has support for fs.access() and fs.accessSync(). See #79 for what is covered by the tests. I'm uncertain how fs.access() works on Windows (without uid/gid) - so the behavior should not be trusted there for now. Any Windows expertise is welcome.