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.
As part of this change I investigated a few projects to see how they are doing this such as upgrade status and upgrade rector and they both have something similar to this but both do it in different ways.
I think this is the definitive method of determining the vendor bin and gives a centralised method of accessing this information so many projects doing have to add it themselves.
One minor issue i found this this is that in my clients config the config.bin-dir is set to
bin/
which means that when the vendor dir is returned it has the trailing /. so when you do something like$bin = $drupalFinder->getVendorDir() . '/rector';
you will get
/composer_root/bin//rector
. this is ok, but a little messy. But I am also assuming it you set config.vendor-dir to something like 'vendor-here/' then the same issue will happen.