Closed adamkiss closed 9 months ago
I see how it can make sense. At first I was a bit worried about possible issues where a index.php
is in the directory three levels up for unrelated reasons. But given the installation with Composer, that could only be the project where the CLI was required locally or ~/.composer/index.php
if required globally. So both cases should be fine.
Alternatively we could consider a --root
flag to manually pass the site root. Then it will also work with a globally installed CLI. But I'd also be fine with your solution.
I think both are preferable? This one's quite cheap (four checks at most), so you can merge this, and I can PR --root
check
When you call Kirby CLI via absolute path (e.g.: cron jobs, daemons, etc.), the working directory is set to whatever the running program deems a good idea (often home directory).
Since this is pure composer plugin, we can be be almost 100% sure that the bootstrap script looking for index() lives in
__ROOT__/vendor/getkirby/cms/bootstrap.php
, and look for the possible index with this expectation.I haven't added any tests, because I have no idea how to test
__DIR__
calls, but since it's a very simple duplication of an existing check… manually testing it, it works on my machine 👍🏻😀