Example #1
0
 public function testRemoveAnsiRemovesAnsiCharactersFromString()
 {
     $results = remove_ansi(chr(27) . "[1mBold " . chr(27) . "[31;42mon green" . chr(27) . "[0m" . chr(27) . "[m");
     $this->assertEquals('Bold on green', $results);
 }
Example #2
0
 /**
  * Attempts to update Composer.
  *
  * Returns true if Composer was updated, false if not.
  *
  * @return bool
  * @throws ComposerException
  */
 public function selfUpdate()
 {
     $beforeVersion = $this->getVersion();
     $process = $this->getProcess();
     $processCommand = trim($this->findComposer() . ' self-update');
     $process->setCommandLine($processCommand);
     $this->log->info('Running Composer command', ['command' => $processCommand]);
     $process->run();
     if ($process->isSuccessful() == false) {
         $composerError = remove_ansi($process->getErrorOutput());
         $this->log->error('Composer self update process failure', ['composer' => $composerError]);
         throw new ComposerException('There was an error updating Composer');
     }
     $afterVersion = $this->getVersion();
     if ($beforeVersion == $afterVersion) {
         return false;
     }
     return true;
 }