wp-cli / autoload-splitter

MIT License
3 stars 3 forks source link

Use vendor-dir from composer config #6

Closed JPry closed 7 years ago

JPry commented 7 years ago

Related to #5.

I have a project with a custom setting for vendor-dir. In attempting to include wp-cli/wp-cli as a dependency, I was getting the following error from this repo:

[ErrorException]
include_once(/<path>/vendor/wp-cli/wp-cli/php/WP_CLI/AutoloadSplitter.php): failed to open stream: No such file or directory

I was able to resolve the error with the following config setting:

    "extra": {
        "autoload-splitter": {
            "splitter-location": "<custom directory>/wp-cli/wp-cli/php/WP_CLI/AutoloadSplitter.php"
        }
    }

While this works, I think that the fallback for the AutoloadSplitter location should use the configured vendor-dir setting for Composer, rather than the hardcoded vendor/ directory. While it is currently possible to override the hardcoded option with a config extra value, this shouldn't be necessary for a custom vendor directory.

This PR updates the WP_CLI\AutoloadSplitter\ComposerPlugin class to properly account for the configured vendor-dir from Composer.

schlessera commented 7 years ago

@JPry Thanks for the PR.

We currently don't have a test for this particular use case, so before I review and merge your PR, I want to make sure we have a test that currently breaks and that your PR will fix.

I will ping you as soon as that test is ready, so we can merge master and verify this PR.

JPry commented 7 years ago

@schlessera Would the test you're describing live in this repo, or the main WP CLI repo? Or even somewhere else entirely?

schlessera commented 7 years ago

@JPry In the wp-cli/wp-cli repo: https://github.com/wp-cli/wp-cli/issues/4137

JPry commented 7 years ago

@schlessera @pierre-dargham This test has been updated with the latest changes to master.