/** * Deploy update */ protected function deployUpdate() { // ################## // Backup // ################## $backupPath = $this->cliToolsCommandPath . '.bak'; $this->output->writeln('<comment> Backup current version to ' . $backupPath . '</comment>'); if (is_file($backupPath)) { unlink($backupPath); } rename($this->cliToolsCommandPath, $backupPath); // ################## // Deploy // ################## $this->output->writeln('<comment> Move new version to ' . $this->cliToolsCommandPath . '</comment>'); // Move to current location rename($this->cliToolsUpdatePath, $this->cliToolsCommandPath); if ($this->application->isRunningAsRoot()) { // Apply owner chown($this->cliToolsCommandPath, $this->cliToolsCommandPerms['owner']); // Apply group chgrp($this->cliToolsCommandPath, $this->cliToolsCommandPerms['group']); } // Apply perms chmod($this->cliToolsCommandPath, $this->cliToolsCommandPerms['perms']); }
/** * Applies the style to a given text. * * @param string $text The text to style * * @return string */ public function apply($text) { $ret = $text; // ################## // Padding // ################## if (!empty($this->padding)) { $ret = $this->padding . $ret; } // ################## // Wrap // ################## if (!empty($this->wrap)) { list($width) = $this->application->getTerminalDimensions(); $length = strlen($text); $wrapLength = (int) ($width - $length - 2) / 2 * 0.5; if ($wrapLength >= 1) { $ret = str_repeat($this->wrap, $wrapLength) . ' ' . $ret . ' ' . str_repeat($this->wrap, $wrapLength); } } $ret = parent::apply($ret); // ################## // Padding // ################## if (!empty($this->paddingOutside)) { $ret = $this->paddingOutside . $ret; } return $ret; }