Skip to content

Commit

Permalink
Merge pull request #6 from DarkCs/master
Browse files Browse the repository at this point in the history
Fixed output location on Windows
  • Loading branch information
omnilight committed Sep 27, 2015
2 parents 6e54c09 + a156310 commit 5aa7c69
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -82,6 +82,7 @@ class Event extends Component
public function __construct($command, $config = [])
{
$this->command = $command;
$this->_output = $this->getDefaultOutput();
parent::__construct($config);
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -618,4 +619,13 @@ public function getExpression()
{
return $this->_expression;
}
}

public function getDefaultOutput()
{
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
return 'NUL';
} else {
return '/dev/null';
}
}
}

0 comments on commit 5aa7c69

Please sign in to comment.