/** * * {@inheritDoc} * */ public function doDeploy(ServerInterface $server, array $options, $dryRun) { if (PHP_OS != "WIN32" && PHP_OS != "WINNT" && PHP_OS != "Windows") { throw new \Exception("This deployer running only Windows OS. This OS is " . PHP_OS); } $xcopyOptions = isset($options['xcopy_options']) ? $options['xcopy_options'] : '/D /E /F /K /Y /I'; // Exclude file $excludeFile = null; if (isset($options['xcopy_exclude'])) { $excludeOption = $options['xcopy_exclude']; } else { $excludeOption = $options['rsync_exclude']; } if (isset($excludeOption)) { $excludeFile = $excludeOption; if (false === file_exists($excludeFile)) { throw new \InvalidArgumentException(sprintf('The exclude file "%s" does not exist.', $excludeFile)); } $excludeFile = realpath($excludeFile); } $exclude = ''; if (null !== $excludeFile) { $exclude = sprintf('/EXCLUDE:%s', $excludeFile); } $target = trim($server->getDir()); $target = substr($server->getDir(), 0, strlen($server->getDir()) - 1); $command = sprintf('xcopy %s %s %s %s', ".", $target, $xcopyOptions, $exclude); print_r($command); print "\n"; $result = system($command); print $result; print "\n"; $commands = isset($options['commands']) ? $options['commands'] : array(); $this->execCommands($server, $commands); }
/** * {@inheritDoc} */ public function doDeploy(ServerInterface $server, array $options, $dryRun) { $rsyncOptions = isset($options['rsync_options']) ? $options['rsync_options'] : '-azC --force --delete --progress'; // Exclude file $excludeFile = null; if (isset($options['rsync_exclude'])) { $excludeFile = $options['rsync_exclude']; if (false === file_exists($excludeFile)) { throw new \InvalidArgumentException(sprintf('The exclude file "%s" does not exist.', $excludeFile)); } $excludeFile = realpath($excludeFile); } $exclude = ''; if (null !== $excludeFile) { $exclude = sprintf('--exclude-from \'%s\'', $excludeFile); } $ssh = ''; if (22 !== $server->getPort()) { $ssh = sprintf('-e "ssh -p%d"', $server->getPort()); } $login = sprintf('%s@%s:%s', $server->getUser(), $server->getHost(), $server->getDir()); $command = sprintf('rsync %s %s %s ./ %s %s', $dryRun ? "--dry-run" : "", $rsyncOptions, $ssh, $login, $exclude); system($command); }