-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Tweaks the plugin directory search #5819
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
Conversation
|
I'm wondering if this new behaviour could be tested somehow 🤔 Otherwise, it won't take long for someone to break it 😅 |
src/common/load-plugins.js
Outdated
| // In some fringe cases (ex: files "mounted" as virtual directories), the | ||
| // isDirectory(resolvedPluginSearchDir) check might be false even though | ||
| // the node_modules actually exists. | ||
| if (!isDirectory(nodeModulesDir) && !isDirectory(resolvedPluginSearchDir)) { |
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.
From CI:
✘ prettier/prettier Replace `!isDirectory(nodeModulesDir)·&&·!isDirectory(resolvedPluginSearchDir)` with `⏎········!isDirectory(nodeModulesDir)·&&⏎········!isDirectory(resolvedPluginSearchDir)⏎······`
src/common/load-plugins.js:63:11
if (!isDirectory(nodeModulesDir) && !isDirectory(resolvedPluginSearchDir)) {
^
✘ 1 problem (1 error, 0 warnings)
|
Maybe by adding a mock that would call the real |
|
Added a test 😃 |
|
Linting is failing again in CI: The first error should be fixed by running this: In the second case, the answer seems to be: if (path.basename(filename) === `virtualDirectory`) {
return origStatSync(path.join(__dirname, __filename));
}
return origStatSync(filename); |
|
Woops, forgot to commit the fix, here it is! |
|
Ping? 🙂 |
|
Thanks for contributing! |
|
Any idea when this could be released? It would fix a problem that blocks us from using prettier within the Yarn repo 😀 |
|
I’m not sure, but in the meantime you can install |
Basically with Yarn v2 we'll make it possible to load files directly from within the zip archive. For now this will be implemented by patching the fs module so that Node is able to see the files within the archive. The problem is that in order to work well with rimraf and similar crawlers, the archive itself mustn't be stat'd as a directory. This is problematic in Prettier because you actually check it by default.
With this change the node_modules isDirectory check will succeed, and will shortcut the one to check whether its parent directory is a directory.