Skip to content

Commit

Permalink
Ensure :wp is first in execute argument list
Browse files Browse the repository at this point in the history
SSKKit only allows using `command_map` on the first argument of the
`execute` method.
Trying to use this on a shared staging environment where I am unable to
install `wp` as a global command resulted in using:
```ruby
SSHKit.config.command_map[:wp] = "$(if [ $(which wp) ]; then echo 'wp'; else echo 'php55-cli #{shared_path.join(wp-cli.phar)'; fi)"
```
(See lavmeiker#18)
  • Loading branch information
davestevens committed Jun 18, 2015
1 parent 4fb16d4 commit 1aaebd0
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/capistrano/tasks/wpdb.rake
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ namespace :wpcli do
unless roles(:dev).empty?
on roles(:dev) do
within fetch(:dev_path) do
execute :gunzip, "<", fetch(:wpcli_local_db_file), "|", :wp, :db, :import, "-"
execute :rm, fetch(:wpcli_local_db_file)
local_tmp_file = fetch(:wpcli_local_db_file).gsub(/\.gz$/, "")

execute :gunzip, "-c", fetch(:wpcli_local_db_file), ">", local_tmp_file
execute :wp, :db, :import, local_tmp_file
execute :rm, fetch(:wpcli_local_db_file), local_tmp_file
execute :wp, "search-replace", fetch(:wpcli_remote_url), fetch(:wpcli_local_url), fetch(:wpcli_args) || "--skip-columns=guid"
end
end
else
run_locally do
execute :gunzip, "<", fetch(:wpcli_local_db_file), "|", :wp, :db, :import, "-"
execute :rm, fetch(:wpcli_local_db_file)
local_tmp_file = fetch(:wpcli_local_db_file).gsub(/\.gz$/, "")

execute :gunzip, "-c", fetch(:wpcli_local_db_file), ">", local_tmp_file
execute :wp, :db, :import, local_tmp_file
execute :rm, fetch(:wpcli_local_db_file), local_tmp_file
execute :wp, "search-replace", fetch(:wpcli_remote_url), fetch(:wpcli_local_url), fetch(:wpcli_args) || "--skip-columns=guid"
end
end
Expand All @@ -62,8 +68,11 @@ namespace :wpcli do
on roles(:web) do
upload! fetch(:wpcli_local_db_file), fetch(:wpcli_remote_db_file)
within release_path do
execute :gunzip, "<", fetch(:wpcli_remote_db_file), "|", :wp, :db, :import, "-"
execute :rm, fetch(:wpcli_remote_db_file)
remote_tmp_file = fetch(:wpcli_remote_db_file).gsub(/\.gz$/, "")

execute :gunzip, "-c", fetch(:wpcli_remote_db_file), ">", remote_tmp_file
execute :wp, :db, :import, remote_tmp_file
execute :rm, fetch(:wpcli_remote_db_file), remote_tmp_file
execute :wp, "search-replace", fetch(:wpcli_local_url), fetch(:wpcli_remote_url), fetch(:wpcli_args) || "--skip-columns=guid"
end
end
Expand Down

0 comments on commit 1aaebd0

Please sign in to comment.