baudehlo / node-fs-ext

Extras missing from node's fs module
MIT License
101 stars 45 forks source link

Don't override fs module #89

Closed ikokostya closed 4 years ago

ikokostya commented 4 years ago

Problem

Now node-fs-ext overrides fs module, i.e. adds new constants to it. Because Node.js modules are cached, other modules got implicitly redefined fs module.

Also, since Node.js 11 constants are not extensible anymore https://github.com/baudehlo/node-fs-ext/issues/76 and deprecated since Node.js 6. So, there is no way to get them in new versions of Node.js (only import binding file directly).

Proposal

Instead node-fs-ext can export own constants and doesn't touch core fs module:

const {fcntl, constants} = require('fs-ext');

fs.fcntl(fd, constants.F_SETLK, constants.F_WRLCK, (err) => { ... }); 

Related Issues

https://github.com/baudehlo/node-fs-ext/issues/81

baudehlo commented 4 years ago

I agree completely. It made sense at the time, but Node has matured a lot.

However someone else is going to have to create a PR that does this.

ikokostya commented 4 years ago

However someone else is going to have to create a PR that does this.

I created PR https://github.com/baudehlo/node-fs-ext/pull/90. Please take a look.