Tweaks the plugin directory search#5819
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.
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 https://github.com/prettier/prettier/blob/master/tests_integration/runPrettier.js#L54-L56 |
|
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.