-
Notifications
You must be signed in to change notification settings - Fork 64
fix: follow symlinks on build-ideal-tree add #129
Conversation
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.
Important thing to note is that I brought this code to my local cli and did a decent round of e2e testing, linking things to global space, linking from there into local projects and overall everything works as expected now 😁
@@ -55,7 +55,7 @@ const addSingle = ({pkg, spec, saveBundle, saveType, path}) => { | |||
pkg[type] = pkg[type] || {} | |||
if (rawSpec !== '' || pkg[type][name] === undefined) { | |||
// if we're in global mode, file specs are based on cwd, not arb path | |||
pkg[type][name] = specType === 'file' || specType === 'directory' | |||
pkg[type][name] = specType === 'file' |
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.
this was introduced in #125 as a way to compensate for the wrong parsed links and should not be necessary anymore
spec.name = mani.name | ||
return spec | ||
}) | ||
const currpath = this[_global] ? process.cwd() : this.path |
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.
@isaacs I decided to leave this here for now, we can revisit it later
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.
We can land on a separate commit, but ought to get it fixed, may as well pull in with this changeset.
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.
eh, let's land it in a sep commit, maybe even better sep PR, let's thing about future us trying to bisect something 😂
|
||
spec.name = mani.name | ||
return spec | ||
} |
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.
This was just a small refactor for readability since when adding the _followSymlinkPath
method (that is now below) things got gnarly in this part of the code
Symlinks were being tracked as invalid when loading actual trees since their realpath wouldn't match, given that build-ideal-tree was just preserving the fetchSpec read from npm-package-arg when adding new packages to the ideal tree. This change fixes it by properly parsing and following symlinks realpaths at the moment they're added to the ideal tree.
0aaf65c
to
5c50c0a
Compare
/* istanbul ignore else - same as the ignored catch above */ | ||
if (real) { | ||
const { name } = spec | ||
spec = npa(`file:${relpath(this.path, real)}`, this.path) |
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.
the new spec gets npa parsed relative to this.path
, so that's what will end up in resolved
, in the package.json
, etc - also something I want to validate that makes sense in the impl 😊
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.
Small nit that we should use single shared rpcache
and stcache
members for buildIdealTree and loadActual.
Otherwise LGTM.
spec.name = mani.name | ||
return spec | ||
}) | ||
const currpath = this[_global] ? process.cwd() : this.path |
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.
We can land on a separate commit, but ought to get it fixed, may as well pull in with this changeset.
691f71b
to
6ae40a7
Compare
Approved over pair session review
Symlinks were being tracked as invalid when loading actual trees since
their realpath wouldn't match, given that build-ideal-tree was just
preserving the fetchSpec read from npm-package-arg when adding new
packages to the ideal tree.
This change fixes it by properly parsing and following symlinks
realpaths at the moment they're added to the ideal tree.