From a156310499b79c9622f86100791e34c8e031dcb0 Mon Sep 17 00:00:00 2001 From: Dark_Cs Date: Sun, 27 Sep 2015 21:16:12 +0300 Subject: [PATCH] fixed output location on windows --- Event.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Event.php b/Event.php index 6b4f014..169147c 100644 --- a/Event.php +++ b/Event.php @@ -59,7 +59,7 @@ class Event extends Component * * @var string */ - protected $_output = '/dev/null'; + protected $_output = null; /** * The array of callbacks to be run after the event is finished. * @@ -82,6 +82,7 @@ class Event extends Component public function __construct($command, $config = []) { $this->command = $command; + $this->_output = $this->getDefaultOutput(); parent::__construct($config); } @@ -524,7 +525,7 @@ public function sendOutputTo($location) */ public function emailOutputTo($addresses) { - if (is_null($this->_output) || $this->_output == '/dev/null') { + if (is_null($this->_output) || $this->_output == $this->getDefaultOutput()) { throw new InvalidCallException("Must direct output to a file in order to e-mail results."); } $addresses = is_array($addresses) ? $addresses : func_get_args(); @@ -618,4 +619,13 @@ public function getExpression() { return $this->_expression; } -} \ No newline at end of file + + public function getDefaultOutput() + { + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + return 'NUL'; + } else { + return '/dev/null'; + } + } +}