protected function move()
{
$exists = $this->pluginExists();
$error = $exists ? 'The plugin could not be updated' : 'The plugin could not be installed';
$success = $exists ? 'The plugin has been updated to version:' : 'The plugin has been installed at version:';
if ($exists) {
$this->output->writeln('<info>Updating plugin...</info>');
} else {
$this->output->writeln('<info>Installing plugin...</info>');
}
$this->output->writeln('<info></info>');
$this->prepare();
$src = $this->source();
$dest = $this->destination();
// overwriting means having to clean the plugin first
if (is_dir($dest)) {
if (!dir::remove($dest)) {
throw new RuntimeException('The old plugin could not be removed before the update');
}
}
if (is_file($src)) {
if (!f::move($src, $dest)) {
throw new RuntimeException($error);
}
} else {
if (is_dir($src)) {
if (!dir::move($src, $dest)) {
throw new RuntimeException($error);
}
} else {
throw new RuntimeException('Invalid source');
}
}
$this->output->writeln('<comment>' . $success . ' "' . $this->version() . '"</comment>');
}