-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix(nm): Reinstall removed module directories #3467
Merged
Merged
Conversation
This file contains 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
larixer
changed the title
fix(nm): Reinstall removed modules directories
fix(nm): Reinstall removed module directories
Sep 21, 2021
larixer
force-pushed
the
larixer/nm-sync-with-disk
branch
from
September 21, 2021 14:46
e801566
to
f0a9c08
Compare
1 task
1 task
merceyz
requested changes
Mar 22, 2022
packages/acceptance-tests/pkg-tests-specs/sources/node-modules.test.ts
Outdated
Show resolved
Hide resolved
merceyz
approved these changes
Mar 22, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What's the problem this PR addresses?
When you remove unplugged directory with pnp linker, it reinstalls the directory again. This behaviour is currently different for the nm linker, it will perform reinstall only when top-level nm folder is removed. The PR changes this for the nm linker, so that both linkers behave the same - when you remove directory deep inside
node_modules
the nm linker reinstalls only this directory and rebuilds the module if needed. The same logic applies to the bin symlinks - removed bin symlinks gets recreated by the nm linker.Closes #3214
How did you fix it?
I use the fact that the nm linker writes
node_modules/.yarn-state.yml
as the last operation of the link step, hence it must have themtime
which is greater than all the files and folders insidenode_modules
. To detect whether the user has removed any module directory insidenode_modules
, it is enough to check whether each parentnode_modules
folder hasmtime >= state_file_mtime
and if it does - the user has modified the directory, we then performreaddir
and find entries deleted by the user, if any, and record these modifications in the preinstall state. The algorithm that diffs install and preinstall state later does the rest of the job of reinstall deleted modules and directories.Checklist