-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added WP-CLI util functions and tasks
- Loading branch information
Showing
4 changed files
with
64 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Provides helper functions for running composer commands | ||
*/ | ||
|
||
namespace Gaambo\DeployerWordpress\Utils\WPCLI; | ||
|
||
const INSTALLER_DOWNLOAD = 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar'; | ||
|
||
function installWPCLI($installPath, $binaryName = 'wp-cli.phar') | ||
{ | ||
\Deployer\run("mkdir -p $installPath"); | ||
\Deployer\run("cd $installPath && curl -sS -O " . INSTALLER_DOWNLOAD . " && chmod +x wp-cli.phar"); | ||
if ($binaryName !== 'wp-cli.phar') { | ||
\Deployer\run("mv $installPath/wp-cli.phar $installPath/$binaryName"); | ||
} | ||
} | ||
|
||
/** | ||
* Runs any WP-CLI command | ||
* Passes on the verbosity flags passed to Deployer CLI | ||
* | ||
* @param string $path Path in which to run WP-CLI command | ||
* @param string $command WP-CLI command to run | ||
* @param string $arguments Command-line arguments to be passed to WP-CLI as a string | ||
* @return string Result/Returned output from CLI | ||
*/ | ||
function runCommand(string $command, string $path = '{{deploy_path}}', string $arguments = '') : string | ||
{ | ||
return \Deployer\run("cd $path && {{bin/wp}} $command $arguments"); | ||
} |