Tweaks the plugin directory search#5819
Merged
j-f1 merged 4 commits intoprettier:masterfrom Feb 5, 2019
Merged
Conversation
Member
|
I'm wondering if this new behaviour could be tested somehow 🤔 Otherwise, it won't take long for someone to break it 😅 |
kachkaev
reviewed
Jan 31, 2019
| // 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)) { |
Member
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)
Contributor
Author
|
Maybe by adding a mock that would call the real |
Contributor
Author
|
Added a test 😃 |
Member
|
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); |
Contributor
Author
|
Woops, forgot to commit the fix, here it is! |
duailibe
approved these changes
Feb 1, 2019
Contributor
Author
|
Ping? 🙂 |
j-f1
approved these changes
Feb 5, 2019
Member
|
Thanks for contributing! |
1 task
Contributor
Author
|
Any idea when this could be released? It would fix a problem that blocks us from using prettier within the Yarn repo 😀 |
Member
|
I’m not sure, but in the meantime you can install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.