-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added file (--file and -f) option to deployer allowing to specify which deploy script to use #86
Conversation
…ch deploy script to use
Hold off on the merge, I found a bug. |
from http://php.net/manual/en/function.realpath.php
So if we've already determined the realpath call has failed it saves us from doing any other checks |
both variants: (is_file($file) && is_readable($file)) and $file !== false && is_file($file) && is_readable($file) have same behaviors, If you have another opinion, say please |
Check this line:
I'm using realpath in order to create an absolute path to the file no matter if you give it a relative path (--file=scripts/site.php) or an absolute one (--file=/var/deploy/site.php). Realpath will return false if the file does not exist (or if the function fails for any other reason). Therefore by doing a simple check to see if $deployFile is already false I save from having to hit the filesystem again by calling is_file. If $realpath is false already then calling is_file is superfluous and just leads to a wasted filesystem call. I guess it's a matter of which is more wasteful, a call to the file system or a boolean comparison. |
Thanks @AlexStansfield, I understood your opinion, it's a small optimization. |
ok, I will remove it |
Due to the way that Symfony\Component\Console\Input\ArgvInput works this is actually a lot harder to implement than expected. I'm not sure if there is a nice way without creating our own Input class. The reason being that it's pretty strict about the options and arguments passed to it. However deploy.php file itself adds options and arguments. So if I try to use the name of the stage I want to deploy to the script fails on too many arguments as it's not imported the deploy.php file yet so doesn't the stage argument hasn't been defined. |
I'll will take your code to v3, and try to implement this without creation own Input class. Try to keep KISS. 👾 |
Good luck |
Added in 9c37344 |
Issue #67
Will accept relative or absolute paths.
Example usage:
php bin/deploy --file=/home/alex/sites/deploy-scripts/wordpress.php deploy
php bin/deploy --file=deploy-scripts/anothersite.php deploy
php bin/deploy -fdeploy-scripts/wordpress.php deploy