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

createRequireFromPath does not support directories with a trailing slash #27527

Closed
MylesBorins opened this issue May 2, 2019 · 6 comments
Closed
Assignees

Comments

@MylesBorins
Copy link
Contributor

Follow up from e5c8be2

TL;DR

createRequireFromPath('/path/to/dir') has unexpected behavior as it is treated as a file not a directory... createRequireFromPath('/path/to/dir/') works as expected.

Seems like the only way forward would be to introduce a synchronous file / directory stat... which imho is undesirable but I totally see why this creates unexpected behavior.

/cc @BridgeAR @addaleax @devsnek

@MylesBorins MylesBorins self-assigned this May 2, 2019
@mscdex
Copy link
Contributor

mscdex commented May 2, 2019

Does it really matter since that method is about to be doc-deprecated anyway (#27405)?

@MylesBorins
Copy link
Contributor Author

@mscdex since createRequire uses it under the hood the behavior is inherited.

@addaleax
Copy link
Member

addaleax commented May 2, 2019

This actually seems like the expected behaviour to me?

@Fishrock123
Copy link
Contributor

Shouldn't createRequireFromPath() raise an error if the path is not (or does not quack like) a directory?

@MylesBorins
Copy link
Contributor Author

@Fishrock123 since it is a wrapper around new Module it actually expects a file to be passed, not a directory.

import.meta.url for example is a file path, not directory. So if there was an error for non paths then import.meta.url would error

@MylesBorins
Copy link
Contributor Author

afaik this was properly fixed by ef51cc8

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

No branches or pull requests

4 participants