drupal-finder
drupal-finder copied to clipboard
Add new method ::getVendorBin()
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.
I will note that the docs for the vendor-bin config don't include a trailing slash:
Defaults to
vendor/bin.
https://getcomposer.org/doc/06-config.md#bin-dir
Until this project adds it, use the Composer API for this - https://getcomposer.org/doc/07-runtime.md#binary-bin-dir-path-in-binaries