Repository navigation
Adds symlinking of package binaries to the project at install - #194
Conversation
|
@jamiebuilds Just wanted to get your thoughts on this. We currently have this check in the symlinking step. bolt/src/utils/symlinkPackageDependencies.js Lines 130 to 134 in 838010d This causes this feature to fail if you run In your opinion, should we remove this check (not 100% sure if it's required?) or should we just loosen it to also check if the symlink points to a Thoughts |
de67b8d to
b71ef8a
Compare
b71ef8a to
731f7c8
Compare
| ]); | ||
|
|
||
| expect(publish({ cwd })).rejects.toBeInstanceOf(BoltError); | ||
| await expect(publish({ cwd })).rejects.toBeInstanceOf(Error); |
There was a problem hiding this comment.
@lachlanhunt Just FYI, found why the test below was failing and also found that this test shouldn't have been passing. :S
We weren't awaiting on the expect.
There's another interesting thing here, we can't check for instanceOf(BoltError) because on lower versions of node it just comes through as "Error". Weird.
| actualBinFileRelative | ||
| ); | ||
|
|
||
| if (!pathIsInside(actualBinFile, project.pkg.nodeModules)) { |
There was a problem hiding this comment.
Discussed with @jamiebuilds and we're removing this as it was for future plans around linking multiple bolt repos that didn't come to fruition.
|
|
||
| symlinksToCreate.push({ src, dest, type: 'exec' }); | ||
| // Just in case the symlink is already added (it might have already existed in the projects bin/) | ||
| if (!symlinksToCreate.find(symlink => symlink.dest === dest)) { |
There was a problem hiding this comment.
Just to explain this check:
I noticed that when running install twice in a row I'd get an error about a symlink already being created. Originally I assumed this must have been from my added code (which hypothetically should be fine, the symlink command rimrafs existing symlinks if they are there).
Upon investigation I found it it was happening in symlinkPackageDependencies because a symlink was being added to symlinksToCreate twice, once because it was in the root dependencies and once because it was an internal dependency.
This check was the least intrusive way to fix the issue.
A couple of other solutions could be:
- Remove all the code that symlinks binaries between packages and let this be taken care of by
symlinkPackagesBinariesToProject. It would copy all binaries from packages into the root .bin and then we'd automatically pick them all up anyway. There's no problem with this imo, the main difference would be that all packages would now have bin's from other internal packages, where as previously they would only get them if they had a dependency (this is not much different to all packages getting a link to all root external bins imo) - Run the symlinking code in serial rather than parallel. Not a great solution, it would solve the problem because each time we tried to make a symlink it would always delete first if there was an existing one, this would be fairly slow however.
- We could rethink how we do all the symlinking of binaries into packages. This currently actually takes a very long time for some reason. We could investigate possibly symlinking the bin directory instead? This would be the most dangerous change imo.
Fixes #187