Skip to content

Use path relative to command to retrieve router.php#21

Merged
schlessera merged 4 commits intomasterfrom
conditional-path
Apr 28, 2017
Merged

Use path relative to command to retrieve router.php#21
schlessera merged 4 commits intomasterfrom
conditional-path

Conversation

@danielbachhuber
Copy link
Copy Markdown
Member

Outside of a Phar, we can use __DIR__

Outside of a Phar, we can use `__DIR__`
@danielbachhuber danielbachhuber added bug command:server Related to 'server' command labels Apr 27, 2017
@danielbachhuber danielbachhuber added this to the 10.4 milestone Apr 27, 2017
@danielbachhuber
Copy link
Copy Markdown
Member Author

@schlessera The tests fail in danielbachhuber/host-check-command#4 because of this issue. The source of the problem is the same as wp-cli/scaffold-command#10

There are three paths router.php can be located at, relative to WP_CLI root:

WP-CLI as a standalone project

WP_CLI_ROOT -> ~/
router.php -> ~/vendor/wp-cli/server-command/router.php

WP-CLI as a dependency of the server-command project

WP_CLI_ROOT -> ~/vendor/wp-cli/wp-cli/
router.php -> ~/router.php

WP-CLI and server-command as dependencies of another project

WP_CLI_ROOT -> ~/vendor/wp-cli/wp-cli/
router.php -> ~/vendor/wp-cli/server-command/router.php

@schlessera
Copy link
Copy Markdown
Member

schlessera commented Apr 28, 2017

I still suggest the same approach as I recommended for wp-cli/scaffold-command#10 - base the relative path for router.php on the location of the command, not the location of the WP-CLI framework. This way, you don't have three different scenarios anymore, you only have:

WP_CLI_ROOT -> <base of wp-cli/wp-cli location>
router.php  -> <base of wp-cli/server-command location> . 'router.php'

The fact that they can change their relative positioning between them becomes irrelevant.

@schlessera schlessera merged commit d180ea7 into master Apr 28, 2017
@schlessera schlessera deleted the conditional-path branch April 28, 2017 19:00
@danielbachhuber danielbachhuber changed the title Only attempt to build relative path when inside of Phar Use path relative to command to retrieve router.php Apr 28, 2017
schlessera added a commit that referenced this pull request Jan 5, 2022
Only attempt to build relative path when inside of Phar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:server Related to 'server' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants