-
-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add built-in FileSystem #430
Conversation
@Zxilly @Shivansh-yadav13 please review |
To keep forward-compatibility, maybe legacy node fs can be used as an default implementation? if (typeof global === 'object') {
const fs = __non_webpack_require__('fs');
const defaultFileSystem = {
readFileSync(path, encoding) {
return fs.readFileSync(path, encoding);
},
writeFileSync(path, text, encoding) {
return fs.writeFileSync(path, text, encoding);
},
};
setDefaultFileSystem(defaultFileSystem);
} This is a webpack specific implementation, for possible other bundlers we need more work. Another possible solution is const fs = eval('require("fs")') |
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Ping @Zxilly |
Right now, there are no breaking changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
# [5.24.0](v5.23.2...v5.24.0) (2023-02-17) ### Features * add built-in FileSystem ([#430](#430)) ([999c34c](999c34c))
🎉 This PR is included in version 5.24.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Motivation
The
casbin
can only use the Node.js FileSystem module, when users want to use the custom FileSystem, thecasbin
doesn't support that.Modification
FileSystem
interface, and add default implementFileSystem
toEnforce
,Model
,Config
, andFileAdapter