Esempio n. 1
0
 public function testExecRunsCommandBuilder()
 {
     $shell = new Exec();
     $command = new CommandBuilder('touch');
     $command->addParam($this->testFile);
     $shell->run($command);
     $this->assertTrue(file_exists($this->testFile), sprintf('%s should have been created', $this->testFile));
 }
Esempio n. 2
0
 /**
  * Get the output of the body.
  *
  * @access public
  * @param string $type - Either Command::HTML or Command::TEXT
  * @param mixed $body
  * @return string
  */
 public function getOutput($type, $body)
 {
     $command = new CommandBuilder($this->command);
     $tempFileName = $this->getTmpFile($body);
     //Set output type to $type
     $command->addArgument('mode', $type);
     //Add temporary file as parameter
     $command->addParam($tempFileName);
     $shell = new Exec();
     $shell->run($command);
     unlink($tempFileName);
     return implode("\n", $shell->getOutput());
 }
Esempio n. 3
0
 /**
  * {@inheritDoc}
  * 
  * @see \HcpssBanderson\Provider\ProviderInterface::assemble()
  */
 public function assemble(array $params)
 {
     $params = $this->resolveParams($params);
     $ds = DIRECTORY_SEPARATOR;
     $tempLocation = vsprintf('%s%s%s', [sys_get_temp_dir(), DIRECTORY_SEPARATOR, uniqid($this->getRepoName($params['source']))]);
     $shell = new ShellExec();
     // Clone the repository
     $cloneCommand = new CommandBuilder('git');
     $cloneCommand->addParam('clone')->addParam($params['source'])->addParam($tempLocation);
     $shell->run($cloneCommand);
     // Checkout the branch
     $checkoutCommand = new CommandBuilder('git');
     $checkoutCommand->addFlag('C', $tempLocation)->addParam('checkout')->addParam($params['branch']);
     $shell->run($checkoutCommand);
     // Delete the .git directory
     $ungitCommand = new CommandBuilder('rm');
     $ungitCommand->addFlag('rf')->addParam($tempLocation . $ds . '.git');
     $shell->run($ungitCommand);
     // Create the install location
     $destination = $this->projectBase;
     if ($params['destination']) {
         $destination .= $ds . $params['destination'];
     }
     if (!empty($params['rename'])) {
         $destination .= $ds . $params['rename'];
     }
     if (!file_exists($destination)) {
         $makeDestCmd = new CommandBuilder('mkdir');
         $makeDestCmd->addFlag('p')->addParam($destination);
         $shell->run($makeDestCmd);
     }
     // Move to the install location
     $moveCommand = new Command('mv');
     $moveCommand->addParam(new Param($tempLocation . $ds . '*', false));
     $moveCommand->addParam(new Param($destination, false));
     // Hidden files have to be specially invited
     $moveHiddenCommand = new Command('mv');
     $moveHiddenCommand->addParam(new Param($tempLocation . $ds . '.[!.]*', false));
     $moveHiddenCommand->addParam(new Param($destination, false));
     $shell->run($moveCommand);
     $shell->run($moveHiddenCommand);
     // Remove the old git folder
     $cleanTempCommand = new CommandBuilder('rm');
     $cleanTempCommand->addFlag('rf')->addParam($tempLocation);
     $shell->run($cleanTempCommand);
 }
Esempio n. 4
0
 public function testCanAddMultipleParams()
 {
     $command = new Command('ls');
     $command->addParam('/srv')->addParam('/var');
     $this->assertEquals("ls '/srv' '/var'", (string) $command, 'Command should have multiple options');
 }
 /**
  * Symlinks the new deploy directory to the webroot.
  *
  * @return bool True if the symlink is successful. False otherwise.
  */
 private function deploy()
 {
     $cmd = new Command('cd');
     $cmd->addParam(dirname($this->webroot))->addSubCommand('&&')->addSubCommand('ln')->addFlag('fs')->addParam($this->installDir)->addParam($this->webroot);
     return $this->ex($cmd);
 }