Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Set up the package index for WP-CLI
#!/usr/bin/env bash
if [ -z "$INSTALL_DIR" ]; then
INSTALL_DIR=$HOME/.wp-cli
fi
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR"
if [ ! -x composer.phar ]; then
echo "Installing Composer in $INSTALL_DIR"
echo "-------------------"
curl -sS https://getcomposer.org/installer | $WP_CLI_PHP
if [ $? -gt 0 ]; then
exit 1
fi
fi
if [ ! -f composer.json ]; then
echo "Creating composer.json file in $INSTALL_DIR"
$COMPOSER init --stability dev --no-interaction
$COMPOSER config bin-dir bin
$COMPOSER config vendor-dir vendor
fi
echo "Ensuring the package index is available in composer.json"
$COMPOSER config repositories.wp-cli composer http://wp-cli.org/package-index/
if [ ! -f config.yml ]; then
echo "Creating config.yml file in $INSTALL_DIR"
echo "require:\n - vendor/autoload.php" > config.yml
else
echo "WARNING: Make sure you have vendor/autoload.php inside config.yml"
fi
echo "Setup completed."
@scribu

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment