PageRenderTime 50ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/transition/tasks/exec.php

https://github.com/antz29/transition
PHP | 33 lines | 22 code | 5 blank | 6 comment | 3 complexity | 4b8ce7ea1b70723173e70c42a225bb90 MD5 | raw file
  1. <?php
  2. /**
  3. * task_export
  4. *
  5. * Allows you to execute an arbitary command
  6. *
  7. */
  8. class task_exec extends Task {
  9. function exec() {
  10. $command = str_replace('{SESSION_ROOT}',SESSION_ROOT,$this->_opts['command']);
  11. $command = str_replace('{TARGET}',$this->_opts['_target'],$command);
  12. $command = str_replace('{PROJECT}',$this->_opts['_project'],$command);
  13. $command = str_replace('{RELEASE}',$this->_opts['_target'],$command);
  14. $desc = isset($this->_opts['desc']) ? $this->_opts['desc'] : false;
  15. if ($desc) {
  16. echo "{$desc}...\n";
  17. }
  18. else {
  19. echo "Executing command {$command} ...\n";
  20. }
  21. $ret = 0;
  22. passthru($command,$ret);
  23. if ($ret) {
  24. throw new Exception('Failed with return '.$ret);
  25. }
  26. echo "Completed command...\n";
  27. }
  28. }