Skip to content
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

Provide own filesystem #56

Closed
Reeywhaar opened this issue Apr 9, 2020 · 2 comments · Fixed by #61
Closed

Provide own filesystem #56

Reeywhaar opened this issue Apr 9, 2020 · 2 comments · Fixed by #61
Assignees

Comments

@Reeywhaar
Copy link

Right now koa-ejs uses only actual node's filesystem.

This becomes trouble when using it with webpack-dev-middleware.

My case: I have server that uses dev middleware to manage compilation for client-side javascript. It keeps all generated assets in memory. I am able to access it's memory filesystem via devMiddlewareInstance.fileSystem which is memfs node's fs api compliant fs.

But koa-ejs accepts only path to root.

So, solution is either to add fs property to koa-ejs options which will accept any node's fs api compliant type. Or second way is to provide root as callback of type (templateFilename: string) => Promise<string>, like: root: (templateFilename) => myfs.readFilePromise(templateFilename).

What do you think?

@3imed-jaberi
Copy link
Member

@Reeywhaar, I think the best apport to keep the code cleaner is by providing an fs option as you mention. If it's okay, for your use case I will ship it in the next release (check it here)

@3imed-jaberi 3imed-jaberi self-assigned this Jul 9, 2022
@3imed-jaberi 3imed-jaberi linked a pull request Jul 9, 2022 that will close this issue
@3imed-jaberi
Copy link
Member

@Reeywhaar, added I will notify you when I can publish the release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants