Closed tyrann0us closed 6 years ago
Yes, you are right. That seams like a better idea. But when I did some research on this, I couldn't find a way to get the installed version of the dependencies on those events.
I tried for example:
$event->getComposer()->getPackage()->getRequires();
But then I only get a list of Link object and not the installed/resolved version: https://getcomposer.org/apidoc/1.3.0/Composer/Package/Link.html
I could probably read from the lock file but that seams like a bit too much of a hack.
Any ideas?
Try:
$packages = $event
->getComposer()
->getRepositoryManager()
->getLocalRepository()
->getPackages();
If I'm right this is the documentation: https://getcomposer.org/apidoc/1.3.0/Composer/Repository/WritableRepositoryInterface.html#method_getPackages.
Untested, but used in a private package of my organization that also runs scripts on the post-install-cmd
and post-update-cmd
hooks.
Thanks @tyrann0us! That seems to work 👍
I will try to get this done in the new few days.
This is now implemented.
post-package-install
andpost-package-update
will only be executed after package installation/update (see https://getcomposer.org/doc/articles/scripts.md#package-events). But language packs change independently of the package they belong to. At any time, translations can be updated/changed in GlotPress. AFAIK these language updates won't get installed with the currently used hooks.So the more appropriate hooks probably should be
post-install-cmd
andpost-update-cmd
(see https://getcomposer.org/doc/articles/scripts.md#command-events) even if this causes the script to run more frequently.When using the mentioned hooks though, I get the following fatal error:
What do you think? Should the hooks be changed?
Any feedback appreciated! Thanks!