Skip to content

Instantly share code, notes, and snippets.

@JKetelaar
Forked from scribu/package-setup.sh
Last active October 15, 2015 07:53
Show Gist options
  • Save JKetelaar/5b19adc1361521f54cd8 to your computer and use it in GitHub Desktop.
Save JKetelaar/5b19adc1361521f54cd8 to your computer and use it in GitHub Desktop.
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 [ ! -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."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment