Adding verification to the install and update commands to check whether PHPCI is installed.

This commit is contained in:
Dan Cryer 2014-04-10 14:58:26 +00:00
parent 9f182aad91
commit 65f51cff4a
2 changed files with 37 additions and 0 deletions

View file

@ -43,6 +43,8 @@ class InstallCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->verifyNotInstalled($output);
$output->writeln('');
$output->writeln('<info>******************</info>');
$output->writeln('<info> Welcome to PHPCI</info>');
@ -278,4 +280,17 @@ class InstallCommand extends Command
die;
}
}
protected function verifyNotInstalled(OutputInterface $output)
{
if (file_exists(PHPCI_DIR . 'PHPCI/config.yml')) {
$content = file_get_contents(PHPCI_DIR . 'PHPCI/config.yml');
if (!empty($content)) {
$output->writeln('<error>PHPCI/config.yml exists and is not empty.</error>');
$output->writeln('<error>If you were trying to update PHPCI, please use phpci:update instead.</error>');
die;
}
}
}
}

View file

@ -48,8 +48,30 @@ class UpdateCommand extends Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->verifyInstalled($output);
$output->writeln('Updating PHPCI database.');
// Update the database:
$gen = new \b8\Database\Generator(\b8\Database::getConnection(), 'PHPCI', './PHPCI/Model/Base/');
$gen->generate();
$output->writeln('<info>Done!</info>');
}
protected function verifyInstalled(OutputInterface $output)
{
if (!file_exists(PHPCI_DIR . 'PHPCI/config.yml')) {
$output->writeln('<error>PHPCI does not appear to be installed.</error>');
$output->writeln('<error>Please install PHPCI via phpci:install instead.</error>');
die;
}
$content = file_get_contents(PHPCI_DIR . 'PHPCI/config.yml');
if (empty($content)) {
$output->writeln('<error>PHPCI does not appear to be installed.</error>');
$output->writeln('<error>Please install PHPCI via phpci:install instead.</error>');
die;
}
}
}